What's wrong with this

mahmed1

Well-known Member
Joined
Mar 28, 2009
Messages
2,302
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Guys

Sub SelectCell()

Dim ws As Worksheets

ws("Tester").Range("A1").Select
End Sub

Thanks
 

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.
Try like this

Code:
Sub SelectCell()

Dim ws As Worksheets
Set ws = Sheets("Tester")
ws.Range("A1").Select
End Sub
 
Upvote 0
Worksheets is a collection, you just want one sheet. After declaring ws as a worksheet, you need to set a reference to the desired sheet. Finally, unless "Tester" is the active sheet, that line will fail as the cell cannot be selected unless the sheet is active.

Try:
Rich (BB code):
Sub SelectCell()
Dim ws As Worksheet
    
    Set ws = ThisWorkbook.Worksheets("Tester")
    ws.Select
    ws.Range("A1").Select
End Sub
 
Upvote 0
You would need to select the sheet then the cell, or

Code:
Sub SelectCell()
Dim ws As Worksheet
Set ws = Sheets("Tester")
Application.Goto ws.Range("A1")
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,596
Messages
6,179,807
Members
452,944
Latest member
2558216095

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