Boulevardier
New Member
- Joined
- Nov 16, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hello all!
I'm just getting into using the VBA for Excel and learning a lot. I'm currently writing a code that grabs an initial named range, and autofills from that 'Start' range thru a second range defined as 'Whole', and then returns the user to the active cell they were in when they ran the macro.
Right now, if the user hasn't set up the 'Start' and 'Whole' named ranges, the code won't work and they get a runtime error. I'd like the code to begin by checking for the named ranges and if it can't find them, then to display a message box to the user to define them, and end the code. Just a simple 'ok' button in the box.
What I've got so far is:
Sub MetFill()
Set myCell = ActiveCell
Range("Start").Select
Selection.AutoFill Destination:=Range("Whole"), Type:=xlFillDefault
myCell.Select
End Sub
All help would be appreciated, thanks!
--Jimmy
I'm just getting into using the VBA for Excel and learning a lot. I'm currently writing a code that grabs an initial named range, and autofills from that 'Start' range thru a second range defined as 'Whole', and then returns the user to the active cell they were in when they ran the macro.
Right now, if the user hasn't set up the 'Start' and 'Whole' named ranges, the code won't work and they get a runtime error. I'd like the code to begin by checking for the named ranges and if it can't find them, then to display a message box to the user to define them, and end the code. Just a simple 'ok' button in the box.
What I've got so far is:
Sub MetFill()
Set myCell = ActiveCell
Range("Start").Select
Selection.AutoFill Destination:=Range("Whole"), Type:=xlFillDefault
myCell.Select
End Sub
All help would be appreciated, thanks!
--Jimmy