Solved

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

Posted on 2013-11-12
3
253 Views
Last Modified: 2013-11-13
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

0
Comment
Question by:fordraiders
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 51

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39643838
Hi,

 Since strNameBox is a range ( I suppose you want only a cell you have to give the row as well)

Set strNameBox = Range(Cells(1, strColumnBox))

Open in new window


Regards
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39643900
ok Changed:
Dim strNameBox As String

 strNameBox = Target.Offset(0, -1)

This will do it...
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 39644786
Thanks, Got me on the right track anyway.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question