Solved

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

Posted on 2013-11-12
3
240 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
  • 2
3 Comments
 
LVL 50

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
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…

821 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