khatri milan
New Member
- Joined
- Nov 6, 2019
- Messages
- 17
as shown in code below, i have defined two varible m and n and tried to use these variable for addressing a cell like range("cn") in place of range("c4") during first loop, but it shown run time error 1004 , cant i address a range in this way?
Sub test()
Dim diameter As Long
Dim maxcap As Long
Dim m As Integer
Dim n As Integer
For m = 74 To 76
For n = 4 To 22
maxcap = Worksheets("9_Sling Data").Range("cn").Value
If maxcap >= Range("im").Value Then
Range("hm").Value = maxcap
Range("gm").Value = Worksheets("9_Sling Data").Range("an").Value
Range("jm").Value = Round(Range("im").Value / Range("hm").Value, 2)
Exit For
Else
End If
Next n
Next m
End Sub
Sub test()
Dim diameter As Long
Dim maxcap As Long
Dim m As Integer
Dim n As Integer
For m = 74 To 76
For n = 4 To 22
maxcap = Worksheets("9_Sling Data").Range("cn").Value
If maxcap >= Range("im").Value Then
Range("hm").Value = maxcap
Range("gm").Value = Worksheets("9_Sling Data").Range("an").Value
Range("jm").Value = Round(Range("im").Value / Range("hm").Value, 2)
Exit For
Else
End If
Next n
Next m
End Sub