Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50123

macro that loops through a given range of sheets is freezing

$
0
0
I got a similar macro off a forum and adjusted it for my needs. When I first ran it it worked but then crashed excel and I had to go looking for the macro again because I hadn't saved it. Now I must have entered it different because it doesn't work but just freezes excel. I am using Excel 97.
Also what can I add to make it select a blank cell like "K9" before it loops on to the next sheet. The usual code to do that isn't working.
Code:

ws.Range("K9").Select
Here is the macro
Code:

Sub DelCMDatNamFormNotval()
'
' DelCMDatNamFormNotval Macro
' Macro recorded 4/25/2013 by Yin Ju Ping
'

'
    arrSheets = Array("LC1", "LC2", "LC3", "LC4", "LC5", "LC6", "LC7", "LC8", "LC9", "LC10", _
    "LC11", "LC12", "LC13", "LC14", "LC15", "LC16", "LC17", "LC18", "LC19", "LC20", "LC21", _
    "LC22", "LC23", "LC24")
 
    For I = LBound(arrSheets) To UBound(arrSheets)
 
        Set ws = Sheets(arrSheets(I))
 
    ws.Range("D4:G5").Copy
    ws.Range("D4:G5").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False
    ws.Range("B6:G39").Application.CutCopyMode = False
    ws.Range("B6:G39").Copy
    ws.Range("B6:G39").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False
    Next
   
End Sub


Viewing all articles
Browse latest Browse all 50123

Trending Articles