RunRabbit13
New Member
- Joined
- Aug 29, 2014
- Messages
- 12
Trying to use a userform to allow user to select ranges of data and quickly calculate the percent difference. I have been working on this for hours with no positive outcome. I can get it to work when you select one cell (not the code I pasted), but I cannot get ranges to work. If someone know how to make this happen please let me know what I am doing wrong.
Private Sub CommandButton1_Click()
Dim Addr As String
Dim Rng1, Rng2 As Range
Dim Location As Variant
'New Value
Addr1 = RefEdit1.Value
Set Rng1 = Range(Addr1)
'Old value
Addr2 = RefEdit2.Value
Set Rng2 = Range(Addr2)
'Output
Addr3 = RefEdit3.Value
Set Location = Range(Addr3)
Location = (Rng1 - Rng2) / Rng2
End Sub
Private Sub CommandButton1_Click()
Dim Addr As String
Dim Rng1, Rng2 As Range
Dim Location As Variant
'New Value
Addr1 = RefEdit1.Value
Set Rng1 = Range(Addr1)
'Old value
Addr2 = RefEdit2.Value
Set Rng2 = Range(Addr2)
'Output
Addr3 = RefEdit3.Value
Set Location = Range(Addr3)
Location = (Rng1 - Rng2) / Rng2
End Sub