Excel Macro question

texasguy66

New Member
Joined
May 31, 2023
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hello everyone.

My excel template has a macro in it to create an email in outlook to send out information from the workbook. One of the ranges to capture a range of data to copy to the body of the email is

Set rng2 = Sheets("Pivot").Range("D4:M17")

Is there a way that I can have input in the spreadsheet that I can quickly change this range as needed? Currently I go into the macro and manually update.

Thanks in advance.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
One easy way would be to use a named range, and then just refer to that name in VBA.
Then all you have to do on your Excel sheet is change the named range, and it will filter through to your VBA.
See: Refer to Named Ranges
 
Upvote 0
Or maybe
VBA Code:
Set rng2 = Application.InputBox(Prompt:="Select a range", Type:=8)
 
Upvote 0
Solution

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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