Input Box Range to Cell

xxthegiantxx

New Member
Joined
Jan 5, 2017
Messages
24
I am new to VBA and having trouble. I have created a button that i want to prompt a pop up input box that triggers the user to enter a range of cells. I then want to use that range in a formula. However, doing so through the vba may be over my head at this point but if it is a simple process then i would appreciate the answer. At this point all i am trying to get to work is the range to be entered into a designated cell so that i can write a formula to calculate using the range in the designated cell. However, the code i have written does not work if a range of more then one cell is selected. It also enters the value from that range instead of the location which is what could be causing the problem. Please help me correct the code that designates the range to a specific cell. Here is my VBA:

Sub Button3_Click()


Dim Calculated_Range
Set Calculated_Range = Application.InputBox("Calculate Weekly Hours", "Select a Range from Column 'F'", "Enter Range", , , , , 8)


If Calculated_Range Is Nothing Then
MsgBox "No Range Selected"
Else
MsgBox "Range Selected: " & Calculated_Range.Address
End If




Range("R3") = Calculated_Range


End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You didn't say what your formula was. But let's say that you wanted to use it in a Sum formula in cell R3.
Then the last line would look like:
Code:
Range("R3").Formula = "=SUM(" & Calculated_Range.Address & ")"
 
Upvote 0
You are welcome.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,678
Members
449,116
Latest member
HypnoFant

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