Loop code

Mindrage

Board Regular
Joined
Jan 5, 2009
Messages
133
Sub Macro1()
'
Worksheets("Temp").Activate
lrow = Range("D65536").End(xlUp).Row
For i = 0 To lrow
d = 0
f = d + 1
G = "C" & f
If Range(G) = "50" Then
Range("D" & f).Value = Range("D" & f) * -1

Else
Range("D" & f).Value = Range("D" & f)

End If
Next

Dear All,

I need help with the above code, its not looping proper and not sure if the code will work correct as i want. Please could some one check and let me know.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Code:
Sub Macro1()
'
Worksheets("Temp").Activate
lrow = Range("D65536").End(xlUp).Row
For i = 1 To lrow
  G = "C" & i
  If Range(G) = "50" Then
    Range("D" & i).Value = Range("D" & i) * -1
  End If
Next

end sub
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,254
Members
452,900
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top