name of sheet might be problem.

g48dd

Board Regular
Joined
Jan 12, 2009
Messages
101
This macro use to run, then I had to change it a bit to make sure that it ran on Sheet3. I have had many sheets in this workbook and I am wondering if that is starting to cause problems. This is what I have at the top of my macro to make sure it runs on sheet3
Code:
Sub Cartridges1()
Dim ws1 As Worksheet
Set ws1 = Worksheets("Sheet3")

The tree shows that sheet3 is actually Sheet10 it looks like this: Sheet10(Sheet3). The line Set ws1 = Worksheet("Sheet3") is what is highlighted as the problem.

I don't really have to do it this way I think I could remove all that and just put
Code:
      Sheets("Sheet3").Select
    Range("A1").Select
Something like that at the end of the macro that runs before it, which brings up another question... I have about 15 macros and I am just putting:

Call Macro1
Call Macro2
Call Macro3
Call Macro4

but some of these macros will mess things up if a certain sheet is not active before it runs ... like the one I am havin g a problem with sheet3 needs to be active so is it better to call each macro when you have a lot of them? Or is better to just make them all one great big macro? I could just paste one after another I think, I have done that before it worked but it looked to me like it is easier to keep track of problems if make each one seprate. I thought finding problems would be easier. There will only be 8 sheets but about 20 macros when I am done with it.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi, :)

take the code name (the name before the brackets) of the sheet and work with something like that (With - End With). Pay attention to the point.

Code:
Option Explicit
Sub Main()
    With Sheet3
        .Cells(1, 1).Value = "Test"
        .Cells(1, 1).Interior.ColorIndex = 3
    End With
End Sub
 
Upvote 0
Thank you, I can see what you are talking about, I will apply that tomorrow and see what happens.

Ken
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,219
Members
452,895
Latest member
BILLING GUY

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