ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   [ NEED HELP ] Loop in VBA (https://www.excelbanter.com/excel-programming/451465-%5B-need-help-%5D-loop-vba.html)

FOONG KAH LOON

[ NEED HELP ] Loop in VBA
 
Hi all, I'm totally new into VBA. I need to Loop a task from row to row ( about 99 rows). I get some sample Loop coding from the internet and however it seem like din't works for me, anyone here can help me looks at the coding below for the Loop? Thanks alot




Sub For_Loop()

Dim x As Long

' test3 Macro
'
' Keyboard Shortcut: Ctrl+Shift+C

For x = 1 To 100

ActiveWorkbook.RefreshAll
Range("E2:Q2").Select
Selection.Copy
Range("E2").Select
Selection.PasteSpecial xlPasteValues
Range("E2").Select

Next x

End Sub

Claus Busch

[ NEED HELP ] Loop in VBA
 
Hi,

Am Sat, 28 May 2016 21:47:28 -0700 (PDT) schrieb FOONG KAH LOON:

Sub For_Loop()

Dim x As Long

' test3 Macro
'
' Keyboard Shortcut: Ctrl+Shift+C

For x = 1 To 100

ActiveWorkbook.RefreshAll
Range("E2:Q2").Select
Selection.Copy
Range("E2").Select
Selection.PasteSpecial xlPasteValues
Range("E2").Select

Next x

End Sub


you don't need a loop to change the formulas to values.

Try:

Sub Test()
With ActiveSheet.Range("E2:Q100")
.Value = .Value
End With
End Sub


Regards
Claus B.
--
Windows10
Office 2016


All times are GMT +1. The time now is 04:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com