kkrishna


Hi All,

I am working on a script which compares the cell values of two ranges in different workbooks. I could work out the code with the actual workbooks, worksheets and range names manually written in the code before running the script. Now I want to generalize this script to select the workbooks, worksheets and the ranges while running the script. I could select the workbooks by the GetOpenFileName function. Once the workbook is open, I want to scroll to the worksheet, range and then import the information (like "Sheet2" and "A4 D65") into the script just by selecting them. The program has to wait until I select the parameters and then start running again by capturing the selected information.

Please advise how I can do it.

Thanks in advance




Re: Interactive entry of data to the VBA script

Shasur


One option probably is to use the Inputbox to select the sheet and range after GetOpenFileName

Here is a hint

Code Snippet

Sub Get_Sheet_Range()

Dim rSelectedRange As Range

SelectAgain:
Set rSelectedRange = Application.InputBox(prompt:="Select the cell", Type:=8)

If rSelectedRange Is Nothing Then
' You haven't selected
GoTo SelectAgain
End If

' Code to get the selected sheet and range

End Sub

Hope you succeed

Cheers
Shasur







Re: Interactive entry of data to the VBA script

kkrishna

Thanks for the suggestion. I wrote the code on the lines suggested by you with some variations for selecting the worksheet and the range. That works well.

Thanks again for the prompt response.