Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Automatically go to a cell when opening sheet

Being a novice, I depend on the "Masters" in the NG for answers. I
guess I figured out a macro that always goes to the cell I need to
start on in a sheet. My A & B columns are filled out to Row 550, but I
add data in column C.
I'm on Row 209 right now, so I wanted to go to the first blank cell in
column C. I went to the VBE, right clicked the sheet I wanted the
macro in, and used code below.

I posted this because I had a tough time finding a solution to what I
needed. My search keywords weren't doing the trick. Hope this helps
someone, if they need it.



Private Sub Worksheet_Activate()

Application.ScreenUpdating = False

' Macro that automatically goes to cell I needed. My A & B columns
have the years date
' and day filled out, and I work in Columns C thru BK, with many
hidden columns.
' I wanted a macro that went to the first cell I put data in, below
the row I'd
' already filled out. (Which is in column C)
' If your data starts in a different column, adjust the offsets
accordingly.


' Go to last row in Column C, (Excel 2007 version), use 65536 for
earlier versions.
Range("C1048576").Select


' Go to last used cell in column C
Selection.End(xlUp).Select


' Offset that cell up 13 Rows, 2 columns to left.
' This makes column A visible after the macro runs.
ActiveCell.Offset(-13, -2).Select


' Scrolls to that offset and makes it top, left viewable cell.
Application.Goto reference:=ActiveCell, Scroll:=True


' Offsets one more row than first offset did, then 2 columns.
' That puts the active cell near the center of the sheet
(vertically)
ActiveCell.Offset(14, 2).Select


End Sub

' You can make your active cell the top left cell on the sheet by
using
'ActiveCell.Offset(1, 0).Select
' without the single quote, instead of ActiveCell.Offset(-13,
-2).Select
' Then put a single quote in front of ActiveCell.Offset(14, 2).Select
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Automatically go to a cell when opening sheet

Hi

When you turn screenupdating, always be sure to turn it on again. For this
purpose I wouldn't turn off screenupdating.

See my example:

Private Sub Worksheet_Activate()

TargetCol = "C"
LastRow = Rows.Count
Range(TargetCol & LastRow).End(xlUp).Offset(1, 0).Select

End Sub

Hopes it helps

---
Per

"Tim" skrev i meddelelsen
...
Being a novice, I depend on the "Masters" in the NG for answers. I
guess I figured out a macro that always goes to the cell I need to
start on in a sheet. My A & B columns are filled out to Row 550, but I
add data in column C.
I'm on Row 209 right now, so I wanted to go to the first blank cell in
column C. I went to the VBE, right clicked the sheet I wanted the
macro in, and used code below.

I posted this because I had a tough time finding a solution to what I
needed. My search keywords weren't doing the trick. Hope this helps
someone, if they need it.



Private Sub Worksheet_Activate()

Application.ScreenUpdating = False

' Macro that automatically goes to cell I needed. My A & B columns
have the years date
' and day filled out, and I work in Columns C thru BK, with many
hidden columns.
' I wanted a macro that went to the first cell I put data in, below
the row I'd
' already filled out. (Which is in column C)
' If your data starts in a different column, adjust the offsets
accordingly.


' Go to last row in Column C, (Excel 2007 version), use 65536 for
earlier versions.
Range("C1048576").Select


' Go to last used cell in column C
Selection.End(xlUp).Select


' Offset that cell up 13 Rows, 2 columns to left.
' This makes column A visible after the macro runs.
ActiveCell.Offset(-13, -2).Select


' Scrolls to that offset and makes it top, left viewable cell.
Application.Goto reference:=ActiveCell, Scroll:=True


' Offsets one more row than first offset did, then 2 columns.
' That puts the active cell near the center of the sheet
(vertically)
ActiveCell.Offset(14, 2).Select


End Sub

' You can make your active cell the top left cell on the sheet by
using
'ActiveCell.Offset(1, 0).Select
' without the single quote, instead of ActiveCell.Offset(-13,
-2).Select
' Then put a single quote in front of ActiveCell.Offset(14, 2).Select


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i set number in cell to add 1 upon opening sheet Office Admin Excel Programming 2 March 13th 08 08:31 PM
Automatically place text in one cell into cell in another sheet Jack Frost New Users to Excel 2 April 13th 07 03:11 AM
opening sheet, next available cell displayed Stephen New Users to Excel 2 January 5th 07 04:49 PM
How do I automatically rename a sheet with the contents of a cell. michaelspearin Excel Discussion (Misc queries) 3 December 3rd 04 09:27 PM
Excel macro - Opening a sheet in accordance with the value in a particular cell arunjoshi Excel Programming 2 April 28th 04 02:17 PM


All times are GMT +1. The time now is 06:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"