Modifications to code to allow cell references rather than InputBox popup

gmcgough600

New Member
Joined
Nov 21, 2017
Messages
32
Hi,

Trying to modify the code below to allow the direct use of cell references instead of popping up an InputBox. I've tried e.g.
Code:
    Set tags = Range("B2:I2")
but this isn't working. Also wondering why the code below works with
Code:
Set
used only once rather than at the start of each line?


Code:
Dim tags As Range    Dim start_time, end_time As Variant
    Dim time_conversion, time_integer As Long
    Dim server_name As String
    
    Set tags = Application.InputBox("Select the PI Tags", "Obtain Range Object", Type:=8)
    start_time = Application.InputBox("Select start time (dd/mm/yyyy hh:mm:ss) ", "Obtain Range Object")
    end_time = Application.InputBox("Select end time (dd/mm/yyyy hh:mm:ss) ", "Obtain Range Object")
    Interval = Application.InputBox("Select time interval", "Obtain Range Object")
    server_name = Application.InputBox("Select PI Server name / ID", "Obtain Range Object", "XXX-PI")

Thanks
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
You only use Set with objects, not with strings, numbers or variants.
in what way doesn't your first bit of code work?
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,289
Members
449,077
Latest member
Rkmenon

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