tags:

views:

27

answers:

1

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
Doesn't work for the problem I have stated.
gizgok
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
is there a way to activate the sheet but not shift the focus to that sheet
gizgok
@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