Open woorkbook -active sheet -next cell

kctony

New Member
Joined
Apr 14, 2017
Messages
25
Office Version
  1. 365
Platform
  1. Windows
I have been using the following code to open a workbook to a specific sheet and going to the next available row for data entry. It had been working fine. Then in the course of testing, It stopped working and I would get a "ws = nothing" error...

Code:
Private Sub Workbook_Open()
    Dim ws As Worksheet
    'Set ws = ActiveSheet
    Set ws = ActiveWorkbook.Sheets("Contents")
    ws.Cells(ws.Rows.Count, 1).End(xlUp).Offset(1, 0).Select
End Sub

This is probably simple but it is bugging me... I'm still learning but apparently not enough.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
You cannot select a cell on an inactive sheet, try
Code:
Private Sub Workbook_Open()
    Sheets("Contents").Select
    Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Select
End Sub
 
Upvote 0
Thank you but that didn't seem to work.
It now just opens to wherever it was last.
 
Upvote 0
Are you saying that it doesn't take you to the first blank row on the contents sheet?
 
Upvote 0
Yes, that is what I am saying...
It just opens where ever it was when the workbook/worksheet closed.
I'm sure it's me but that is what is happening
 
Upvote 0
Do you always have data in col A for every used row?
 
Upvote 0
Yes... Column A has data.
I click a button to call a form to add new data which populates activecell 1,2 and 3 from left to right starting at the active cell which should be the next available row in column A.
but if the active cell is someplace else in the workbook, that is where it will open. (and that is where the information will populate)
Also, as a little fly in the ointment... I have hyperlinks from the contents page to the corresponding sheets and back. when I hyper link back to the contents page the active cell becomes A!.
thanx for you help... I've been trying but this is becoming a learning experience
 
Upvote 0
Sorry, I think I figured it out...
I had the OpenWorkbook as a separate module and not inside the "ThisWorkbook"
It seems to work now.
Now i just have to make it go there after returning from a hyper link
Thanx again
 
Upvote 0
Glad you sorted it & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,443
Members
448,898
Latest member
drewmorgan128

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