Excel VBA message box to have option for all the data or to choose a range of data

Afpire93

New Member
Joined
Aug 7, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hi all, currently the first column of my VBA is a list of data to include. For example, it starts off from the 2nd row at BAI_2000 follow by 3rd row BAI_2001 all the way till BAI_5000. I did this by just naming it and pulling it down (As shown below). I will like instead for a message box to show up and letting me choose the range. For example a message box letting me choose 2 choices. Choosing to include everything as shown below or to choose the first number e.g BAI_2050 to BAI_2200. Is there a way to do this? Thank you very much.

VBA Code:
Sub Nameproduct()

Range("A2").Value = "BAI_2000"

   Range("A2").Select
    Selection.Autofill Destination:=Range("A2:A5002"), Type:=xlFillDefault
    Range("A2:A5002").Select
    Range("A5000").Select
    Selection.End(xlUp).Select
End Sub
 
Last edited by a moderator:

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hello,

not 100% certain if this is exactly what you are after

VBA Code:
Sub Nameproduct()
    MY_START = InputBox("Please enter first row", "START ROW")
    MY_END = InputBox("Please enter first row", "START ROW")
    Range("A2").Value = "BAI_2000"
    Range("A" & MY_START).Value = "BAI_" & MY_START + 1998
    Range("A" & MY_START).Select
    Selection.AutoFill Destination:=Range("A" & MY_START & ":A" & MY_END), Type:=xlFillDefault
End Sub

is this any use?
 
Upvote 0

Forum statistics

Threads
1,214,922
Messages
6,122,281
Members
449,075
Latest member
staticfluids

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