How do you stay on the active sheet in active cell?

lbass

Board Regular
Joined
Aug 15, 2002
Messages
104
Every time I make a small step forward I get stumped.

VBA
Finds an account number
looks to the right to see if entry already made
if so moves down a row checks account number
if it is not the same then it inserts a row

Selects sheets so all 57 sheets gets the same row inserted

Active cell is now on the first sheet

no longer on the sheet I need to stay on.

I tried to search but don't know what to search for at least I got no hits.

Thanks you guys are really great.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
hi!
save the current sheet name and cell before doing the search.
Something like
sub searchx()
shtname=activesheet.name
curcell=activecell.address
'run your code here
'at the end
worksheets(shtname).Select
range(curcell).select


end sub
 
Upvote 0
I took that step

I changed searchx to LockLocation

Then where run your code here I inserted end sub

Then after at the end I inserted ReturnLocation()

tried putting LockLocation
More Code
then ReturnLocation

And it didn't work Messed up again didn't I
 
Upvote 0
Hi!
make the variable Shtname and curcell global.
Declare it in the top most of your code
Dim Shtname as string
Dim Currcell as string!
i guess this is what you miss.
 
Upvote 0
That did it

Thanks so much

It's tough enough thinking with your feet

Especially hard (I think) when they are both left

Thank you Thank You
 
Upvote 0
Post your code anyway, but:
I changed searchx to LockLocation

Then where run your code here I inserted end sub

Then after at the end I inserted ReturnLocation()

tried putting LockLocation
More Code
then ReturnLocation

End Sub means END SUB, so all of the code after that isn't recognized as viable and won't run. Put "End Sub" at the END of your code and maybe it'll work.

HTH,

Smitty
 
Upvote 0
lbass said:
That did it

Thanks so much

It's tough enough thinking with your feet

Especially hard (I think) when they are both left

Thank you Thank You
I was so happy that Im not alone having both feet left! :beerchug:
 
Upvote 0

Forum statistics

Threads
1,225,726
Messages
6,186,665
Members
453,368
Latest member
xxtanka

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