ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Visual Basics Error - Goto (https://www.excelbanter.com/new-users-excel/256913-visual-basics-error-goto.html)

Shirl

Visual Basics Error - Goto
 
Please help. I keep getting an error from my visual basics code. Click on a
button on a sheet takes you to another sheet within the same workbook then
directly to specific cells. Don't know whats wrong with the code.

Private Sub CommandButton1_Click()
Application.Goto ActiveWorkbook.Sheets("WGTN & KAPITI").Activate
ActiveSheet.Range("Garry").Activate
End Sub
--
Shirl, NZ

Dave Peterson

Visual Basics Error - Goto
 
Either:

Private Sub CommandButton1_Click()
Application.Goto ActiveWorkbook.Sheets("WGTN & KAPITI").Range("Garry"), _
scroll:=true 'or false
End Sub

or

Private Sub CommandButton1_Click()
with ActiveWorkbook.Sheets("WGTN & KAPITI")
.Activate
.range("garry").Activate 'or .select
end with
End Sub

Shirl wrote:

Please help. I keep getting an error from my visual basics code. Click on a
button on a sheet takes you to another sheet within the same workbook then
directly to specific cells. Don't know whats wrong with the code.

Private Sub CommandButton1_Click()
Application.Goto ActiveWorkbook.Sheets("WGTN & KAPITI").Activate
ActiveSheet.Range("Garry").Activate
End Sub
--
Shirl, NZ


--

Dave Peterson


All times are GMT +1. The time now is 11:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com