PC Review


Reply
Thread Tools Rate Thread

Cell and Worksheet Location

 
 
Glenn
Guest
Posts: n/a
 
      10th Jun 2008
I need to establish (programatically find) the activeworksheet and active or
selected cell at the start of a macro I need to write. I need to validate
that the user of the macro is in the right sheet and column and row range
before I run the rest of the macro code.
 
Reply With Quote
 
 
 
 
StumpedAgain
Guest
Posts: n/a
 
      10th Jun 2008
This should do the trick:

Option Explicit
Sub Right_Location()

Dim sheetname As String
sheetname = ActiveSheet.Name

If vbNo = MsgBox(sheetname & " " & ActiveCell.Address & ": Is this the
correct starting location?", vbYesNo) Then
MsgBox ("Please select the correct starting location.")
End
End If

End Sub



"Glenn" wrote:

> I need to establish (programatically find) the activeworksheet and active or
> selected cell at the start of a macro I need to write. I need to validate
> that the user of the macro is in the right sheet and column and row range
> before I run the rest of the macro code.

 
Reply With Quote
 
merjet
Guest
Posts: n/a
 
      10th Jun 2008
Suppose you want "Sheet1" and cell A5 to be the active ones.

If ActiveSheet.Name <> "Sheet1" Or _
ActiveCell.Address <> "$A$5" Then
MsgBox "Blah blah" 'optional
Exit Sub
End If

 
Reply With Quote
 
Glenn
Guest
Posts: n/a
 
      10th Jun 2008
Thanks very much. I believe I'm good to go.

"StumpedAgain" wrote:

> This should do the trick:
>
> Option Explicit
> Sub Right_Location()
>
> Dim sheetname As String
> sheetname = ActiveSheet.Name
>
> If vbNo = MsgBox(sheetname & " " & ActiveCell.Address & ": Is this the
> correct starting location?", vbYesNo) Then
> MsgBox ("Please select the correct starting location.")
> End
> End If
>
> End Sub
>
>
>
> "Glenn" wrote:
>
> > I need to establish (programatically find) the activeworksheet and active or
> > selected cell at the start of a macro I need to write. I need to validate
> > that the user of the macro is in the right sheet and column and row range
> > before I run the rest of the macro code.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Move active cell to same location on each worksheet BeanoKid Microsoft Excel Misc 3 15th Apr 2008 11:29 PM
Using the value of a cell as the location for placing data into another worksheet ksroskel Microsoft Excel Misc 3 28th Aug 2004 12:28 PM
Inputting info on one worksheet and having it post on another worksheet by location tricxster Microsoft Excel Worksheet Functions 1 27th Jul 2004 12:44 PM
Place The Contents Of A Cell From The Active Worksheet Into A Cell On An Inavtive Worksheet Minitman Microsoft Excel Programming 1 25th Feb 2004 04:26 AM
Place The Contents Of A Cell From The Active Worksheet Into A Cell On An Inavtive Worksheet Minitman Microsoft Excel Worksheet Functions 1 25th Feb 2004 04:26 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:04 PM.