Link to home
Start Free TrialLog in
Avatar of Fordraiders
FordraidersFlag for United States of America

asked on

trying to get value from cell -1 from target.column

excel 2010 vba

I have an event:
xlApp_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

where my "Target"
is being passed into the procedure.

What I need:

I determine the value of the Target.Column value  ....by passing a variable
mRangeColumn (this is the Column Number example "6")

Once I determine what value " Target.Value" is...
I want to get the value to the left of Target.Value
Dim strNameBox As Range
Dim strColumnBox As Integer

        On Error Resume Next
        If Target.Column = "" Then
            If Target.Column = mRangeColumn Then
                
             strColumnBox = Target.Column - 1 
                
 strNameBox.Column = strColumnBox <------ error here
"wrong number of arguments or invalid property assignment"

                
               UserForm2.TextBox1.Value = Target.Value
               UserForm2.ComboBox1.Value = strNameBox.Value
            Else
                ' code
            End If
        Else
            ' code
        End If

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Fordraiders

ASKER

ok Changed:
Dim strNameBox As String

 strNameBox = Target.Offset(0, -1)

This will do it...
Thanks, Got me on the right track anyway.