View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
L. Howard L. Howard is offline
external usenet poster
 
Posts: 852
Default Dynamic Offset from an Application.Goto cell = Date or Time

On Tuesday, June 3, 2014 10:42:41 AM UTC-7, GS wrote:
Near the bottom of the code is a Application.Goto monthID statement.


The offset lines shown there work but I need to do the following.




I want to offset from the GoTo cell:


1 column to the right and the first empty cell below row 5 = Time




Will the offset column contain blanks between row5 and last row of

data?



In another macro I need to offset from the GoTo cell:


1 column left and the first empty cell below row 5 = Timee


2 columns left and the first empty cell below row 5 = Date




If this is the same project you posted a link to in your other thread

titled "Chaneg_Event target either of two cells" then can we assume

both macros are called from the same event? If so then both events

share the same ref to the 'found' range object. Perhaps these macros

need an arg so the ref is common to the caller and any called

procedures...



In the calling event:



Dim rngFound

...

Call Scan_In_Check(rngFound)

or

Call Scan_Out_Check(rngFound)

...



In the called events:



(Scan_Out_Check for example)

Use rngFound instead of the local variable 'monthID'

Replace

Set monthID = Sheets(...

with

Set rngFound = Sheets(...



OR

leave as is and add...



If Not monthID Is Nothing Then

Set rngFound = monthID



..where the header for called macros using the ref is...



Sub MyMacro(rng As Range)



..which *only* get called *If Not rngFound Is Nothing* so your

Scan...Check macros can pass a fully qualified ref back to the caller

which can then pass allong to 'MyMacro' like this...



If Not rngFound Is Nothing Then Call MyMacro(rngFound)



OR use the ref for its own purposes...



If Not rngFound Is Nothing Then...





Hi Garry,

Will the offset column contain blanks between row5 and last row of

data?

There will be no blanks.


Yes, it is the same project.

I'll copy you advice to the sheet and see if I can blend it in. May make more sense to me there. I think you are suggesting reducing the many different 'found' names. I have tried to use names that refer to stuff in the code or worksheet to help me keep thing clear. Reducing that aspect by coming from one of the called macros would be nice, IF that is what you mean and IF I can persuade it to work for me.

Thanks for looking in.

Howard