Solved

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

Posted on 2013-11-12
3
217 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 48

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now