Trying to understand a section of VBA Macro from a sheet I've inherited

grabrail

Board Regular
Joined
Sep 6, 2010
Messages
128
Office Version
  1. 365
Platform
  1. Windows
Hi

I have inherited an Excel spreadsheet with VBA code and I am trying to understand one particular part as I need to replicate what its diong on another spreadsheet.

Description

The spreadsheet is made up of 4 tabs, tab is data entry form, tab 2 and 3 are data reference points using various named ranges, tab is a summary page where data is exported from tab 1 to tab 4.

The sheet contains a form, where on a section of tab 1, there are a number of questions with a drop down box, if you select a certain entry in the drop down box the form pops up for further details.

some of the info on the form is populated with the question information and there is a box with a check number, this is pulled in from the question you are doing, each question has its own check number. next to this is a label, which is the description of the check you are diong.

The code that populates this particular box and label is as follows.

VBA Code:
Private Sub IMRef_Change()
    If Me.IMRef.Value <> "" Then
        IMlabel.Caption = Me.IMRef.Column(1)
        CheckNo.Value = Me.IMRef.Column(2)
        
    End If
End Sub

There is various other sections of code on the form and i get what most of it is doing.

I kind of understand the concept of how this is working, Me.IMRef looks like it is referencing a named range made up of 2 columns, one being the check number and the other being the description.

What I cant seem to find is the named range this is referencing or where it is looking for column 1 and column 2.

The only other references to IMRef in the code are where it clears the form when you click the clear button and the section where it is getting the IMRef number from a specific column where the question is asked.

Any pointers for me here that can help me find the source of column1 and column2?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I suspect that IMRef is a combobox with (at least) 3 columns
 
Upvote 0
Solution
ok digging a little deeper, i believe this is selecting a range that is populated by this code

VBA Code:
ActiveCell.Offset(0, 1).Range("A1").Select
    IMRef2 = ActiveCell.Value

IMRef.Value = IMRef2

the activecell when the form pops up is column D and the imref data is in column e hence the offset of 1, but i dont understand why the range is being set as "A1", surely that would just select cell A1?
 
Upvote 0
I suspect that IMRef is a combobox with (at least) 3 columns
You are a legend, it is indeed a combo box and the source is listed as one of the named ranges in the spreadsheet. You have saved me from banging my head on a brick wall
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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