Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have a macro that I want to run on 100 of my 103 worksheets, is there a way
this can be done. My code is: Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Many thanks Mark |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Try;
Sub ClearStockCards() Dim ws As Worksheet For Each ws In Worksheets Select Case UCase(ws.Name) Case "SHEET101", "SHEET102", "SHEET103" 'Do nothing Case Else ws.Range("A7:A36,B8:B36,D3").ClearContents End Select Next ws End Sub -- Regards Dave Hawley www.ozgrid.com "terilad" wrote in message ... I have a macro that I want to run on 100 of my 103 worksheets, is there a way this can be done. My code is: Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Many thanks Mark |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
I cant get this code to work it has error run time error cant change part of a merged cell, the merged cells are on the sheets I dont want to run the macro, when I unmerge the cells it runs the macro on the sheets that I dont want it to run on. Any ideas? Many thanks Mark "ozgrid.com" wrote: Try; Sub ClearStockCards() Dim ws As Worksheet For Each ws In Worksheets Select Case UCase(ws.Name) Case "SHEET101", "SHEET102", "SHEET103" 'Do nothing Case Else ws.Range("A7:A36,B8:B36,D3").ClearContents End Select Next ws End Sub -- Regards Dave Hawley www.ozgrid.com "terilad" wrote in message ... I have a macro that I want to run on 100 of my 103 worksheets, is there a way this can be done. My code is: Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Many thanks Mark |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
Try this. Change this line S = "Sheet1,Sheet2,Sheet3" To the name of the sheets you DON'T want the code to run on Sub ClearStockCards() Dim Ws As Worksheet S = "Sheet1,Sheet2,Sheet3" V = Split(S, ",") For Each Ws In ThisWorkbook.Worksheets If IsError(Application.Match(Ws.Name, V, 0)) Then Ws.Range("D3,A7:A36,B8:B36").ClearContents End If Next Ws End Sub -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "terilad" wrote: I have a macro that I want to run on 100 of my 103 worksheets, is there a way this can be done. My code is: Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Many thanks Mark |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
If the 100 worksheets are the first 100 ones in the order of the worksheet
tabs, then Sub test() For wi = 1 To 100 Worksheets(wi).Select Call ClearStockCards Next wi End Sub -- Regards! Stefi €˛terilad€¯ ezt Ć*rta: I have a macro that I want to run on 100 of my 103 worksheets, is there a way this can be done. My code is: Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Many thanks Mark |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
They are the last 100
Mark "Stefi" wrote: If the 100 worksheets are the first 100 ones in the order of the worksheet tabs, then Sub test() For wi = 1 To 100 Worksheets(wi).Select Call ClearStockCards Next wi End Sub -- Regards! Stefi €˛terilad€¯ ezt Ć*rta: I have a macro that I want to run on 100 of my 103 worksheets, is there a way this can be done. My code is: Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Many thanks Mark |
#7
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
tried editing but not working for me, trying to run macro on sheets I dont
want it to. Mark "Stefi" wrote: If the 100 worksheets are the first 100 ones in the order of the worksheet tabs, then Sub test() For wi = 1 To 100 Worksheets(wi).Select Call ClearStockCards Next wi End Sub -- Regards! Stefi €˛terilad€¯ ezt Ć*rta: I have a macro that I want to run on 100 of my 103 worksheets, is there a way this can be done. My code is: Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Many thanks Mark |
#8
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
If your code doesn't work, please post it next time!
For the last 100 sheets: Sub test() For wi = 4 To 103 Worksheets(wi).Select Call ClearStockCards Next wi End Sub -- Regards! Stefi €˛terilad€¯ ezt Ć*rta: tried editing but not working for me, trying to run macro on sheets I dont want it to. Mark "Stefi" wrote: If the 100 worksheets are the first 100 ones in the order of the worksheet tabs, then Sub test() For wi = 1 To 100 Worksheets(wi).Select Call ClearStockCards Next wi End Sub -- Regards! Stefi €˛terilad€¯ ezt Ć*rta: I have a macro that I want to run on 100 of my 103 worksheets, is there a way this can be done. My code is: Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Many thanks Mark |
#9
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Stefi,
No Joy. Here's my code. Sub MyMacroToClear() For wi = 5 To 7 Worksheets(wi).Select Call ClearStockCards Next wi End Sub Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Thanks Mark "Stefi" wrote: If your code doesn't work, please post it next time! For the last 100 sheets: Sub test() For wi = 4 To 103 Worksheets(wi).Select Call ClearStockCards Next wi End Sub -- Regards! Stefi €˛terilad€¯ ezt Ć*rta: tried editing but not working for me, trying to run macro on sheets I dont want it to. Mark "Stefi" wrote: If the 100 worksheets are the first 100 ones in the order of the worksheet tabs, then Sub test() For wi = 1 To 100 Worksheets(wi).Select Call ClearStockCards Next wi End Sub -- Regards! Stefi €˛terilad€¯ ezt Ć*rta: I have a macro that I want to run on 100 of my 103 worksheets, is there a way this can be done. My code is: Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Many thanks Mark |
#10
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I cant get this code to work it has error run time error cant change part of
a merged cell, the merged cells are on the sheets I dont want to run the macro, when I unmerge the cells it runs the macro on the sheets that I dont want it to run on. Mark "Stefi" wrote: If your code doesn't work, please post it next time! For the last 100 sheets: Sub test() For wi = 4 To 103 Worksheets(wi).Select Call ClearStockCards Next wi End Sub -- Regards! Stefi €˛terilad€¯ ezt Ć*rta: tried editing but not working for me, trying to run macro on sheets I dont want it to. Mark "Stefi" wrote: If the 100 worksheets are the first 100 ones in the order of the worksheet tabs, then Sub test() For wi = 1 To 100 Worksheets(wi).Select Call ClearStockCards Next wi End Sub -- Regards! Stefi €˛terilad€¯ ezt Ć*rta: I have a macro that I want to run on 100 of my 103 worksheets, is there a way this can be done. My code is: Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Many thanks Mark |
#11
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Which sheets do you want to run the macro on? You wrote that they are the
last 100 while your macro run on sheets 5,6,7 (3 sheets). Which is true? Which cells are merged? Which line causes the error? (Which line is highlighted in yellow while debugging? -- Regards! Stefi €˛terilad€¯ ezt Ć*rta: I cant get this code to work it has error run time error cant change part of a merged cell, the merged cells are on the sheets I dont want to run the macro, when I unmerge the cells it runs the macro on the sheets that I dont want it to run on. Mark "Stefi" wrote: If your code doesn't work, please post it next time! For the last 100 sheets: Sub test() For wi = 4 To 103 Worksheets(wi).Select Call ClearStockCards Next wi End Sub -- Regards! Stefi €˛terilad€¯ ezt Ć*rta: tried editing but not working for me, trying to run macro on sheets I dont want it to. Mark "Stefi" wrote: If the 100 worksheets are the first 100 ones in the order of the worksheet tabs, then Sub test() For wi = 1 To 100 Worksheets(wi).Select Call ClearStockCards Next wi End Sub -- Regards! Stefi €˛terilad€¯ ezt Ć*rta: I have a macro that I want to run on 100 of my 103 worksheets, is there a way this can be done. My code is: Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Many thanks Mark |
#12
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
First, it's never a good idea to multipost the same question to different
newsgroups. And it's not a good idea to start a new thread without some indication in the old thread. Option Explicit Sub ReconcileStockCard() Dim wks As Worksheet For Each wks In ActiveWorkbook.Worksheets Select Case LCase(wks.Name) 'names of the sheets to skip Case Is = "sheet9", "sheet13", "sheet33" 'do nothing Case Else With wks .Range("a7:a36,b8:b36,d3,d7:d36").value = "" End With End Select Next wks End Sub I changed the range back to what you used in the other thread. Change it if you need to. terilad wrote: I have a macro that I want to run on 100 of my 103 worksheets, is there a way this can be done. My code is: Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Many thanks Mark -- Dave Peterson |
#13
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I only reposted this as I posted the wrong code initialy and the thread was
getting realy confused and difficult to put the issue across, thanks for your input Dave. Regards Mark "Dave Peterson" wrote: First, it's never a good idea to multipost the same question to different newsgroups. And it's not a good idea to start a new thread without some indication in the old thread. Option Explicit Sub ReconcileStockCard() Dim wks As Worksheet For Each wks In ActiveWorkbook.Worksheets Select Case LCase(wks.Name) 'names of the sheets to skip Case Is = "sheet9", "sheet13", "sheet33" 'do nothing Case Else With wks .Range("a7:a36,b8:b36,d3,d7:d36").value = "" End With End Select Next wks End Sub I changed the range back to what you used in the other thread. Change it if you need to. terilad wrote: I have a macro that I want to run on 100 of my 103 worksheets, is there a way this can be done. My code is: Sub ClearStockCards() Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents End Sub Many thanks Mark -- Dave Peterson . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to run macro on selected sheets with one go? | Excel Discussion (Misc queries) | |||
Printing selected sheets. | Excel Worksheet Functions | |||
Protecting Macro and selected sheets | Excel Discussion (Misc queries) | |||
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? | Excel Worksheet Functions | |||
Multiple sheets selected | Excel Discussion (Misc queries) |