[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Excel VBA - Find row & column address in worksheet based on 2 match scenerios.

Posted on 2013-01-30
7
Medium Priority
?
622 Views
Last Modified: 2013-01-30
Hello Experts,

I have a worksheet where I need to derive the cell.address off 2 variables.

1st variable:
r = "C1" match to Range ("A1:A60") - this will be my row number of that found cell in range

2nd variable:
c = "C2" match to Range ("D1:X1) - this will be my column number of the found cell in range

Then my cell address would be .Cells(r, c) so I can finish my code.  

I am not remembering my stuff here; how to just get the row number or column number.

Thanks,
Michael
0
Comment
Question by:mike637
[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
7 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 total points
ID: 38836512
You can try

r=Range ("A1:A60").find("C1",,,xlwhole).Row
c=Range ("D1:X1").find("C2",,,xlwhole).column
0
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 38836515
if you declare two range objects (one for  Range ("A1:A60"), and one for  Range ("D1:X1"),  you can loop through each range searching for your criteria. Once you find your criteria you can get the address of the cell. Below is a genreal example.
Dim thisRange As Range
Set thisRange = Range("A1:A60") 
Dim searchValue As Integer
Dim targetAddress As String

Dim cell As Variant
searchValue = 21
For Each cell In thisRange
    If cell = searchValue Then
        targetAddress = cell.Address
    End If
Next cell

Open in new window

0
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 38836519
ssaqibh, i like your example better than mine ;-)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 13

Expert Comment

by:Shanan212
ID: 38836524
    Dim r As Long, c As Long
    
        r= Application.WorksheetFunction.Match(Range("C1"), Range("A1:A60"), 0)
        c= Application.WorksheetFunction.Match(Range("C2"), Range("D1:X1"), 0)

Open in new window

0
 

Author Closing Comment

by:mike637
ID: 38836536
Thank you very much!!

Michael
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38836537
aebea, this is the beauty of this site....I often come up with a brilliant solution and then discover that there is a better solution available.
0
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 38836577
saqib, I agree!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
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 will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

656 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