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
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