I have a button in sheet3.On the button click event I'm calling a macro.In the macro I want to select the number of cells that are filled in sheet13.How do I do this
+1
A:
You cannot select cells without changing the focus of your sheet.
Sheets("sheet13").Activate
ActiveSheet.UsedRange.Select
You can, however, apply changes or read data from another sheet without changing focus.
Sheets("sheet13").UsedRange.Font.Bold = True
Msgbox Sheets("sheet13").UsedRange.Cells.Count
variant
2010-09-06 16:37:57
Doesn't work for the problem I have stated.
gizgok
2010-09-06 18:02:53
Please read the question again.I have a button on sheet3.So when I do active sheet it will select the range of sheet3 and not sheet 13 as I need.If you are gonna tell me that I should activate sheet13 and then do this, then that's not what I need coz this switches the focus from sheet3 to sheet13 which I don't want.
gizgok
2010-09-06 19:10:58
is there a way to activate the sheet but not shift the focus to that sheet
gizgok
2010-09-06 19:41:26
@gizgok - Per the second set of lines in the above answer, you can apply changes / read data from a sheet without activating it provided you the range or object you want to modify or read is preceded by Sheets("sheetname").
variant
2010-09-06 20:42:36