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

x
?
Solved

Need to get postion of a value that is found

Posted on 2013-11-20
7
Medium Priority
?
465 Views
Last Modified: 2013-11-20
Almost there. This should the last part of this sub routine that needs to be modified.

Please refer to the comments in the code below.
'A1 - When the "cell.Value" is found get it's Row and Column position    AND
'
'Put the value x from the "Data" sheet acquired by the line...
'    "x = Application.VLookup(s, Worksheets("Data").Range("A:XFD"), 5, 0"
'to the postion found (specified comment A1) which will be in the "DRA Summary" sheet one row above

Sub Get_GQnumber1()
    Dim rng As Range, cell As Range
    Dim lc As Long
    Dim s As String, x As String
    With Worksheets("DRA Summary")
    lc = .Cells(3, Columns.Count).End(xlToLeft).Column

    Set rng = .Range(.Cells(3, 1), .Cells(3, lc))
       
    For Each cell In rng
        If cell.Value Like "GQ-*" Then
            MsgBox cell.Value
            s = Left(cell.Value, InStr(1, cell.Value & " ", " ") - 1)
'A1 - When the "cell.Value" in the "DRA Summary" sheet is found then get it's Row and Column position

            On Error Resume Next
                       
            x = Application.VLookup(s, Worksheets("Data").Range("A:XFD"), 5, 0)
           
'Put the value x from the "Data" sheet acquired by the line...
'    "x = Application.VLookup(s, Worksheets("Data").Range("A:XFD"), 5, 0"
'to the postion found (specified comment A1) which will be in the "DRA Summary" sheet one row above
           
        End If
    Next
    End With
End Sub


Your help with this is greatly appreciated.
Thanks.
0
Comment
Question by:tesla764
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 43

Assisted Solution

by:Saqib Husain, Syed
Saqib Husain, Syed earned 80 total points
ID: 39663250
you can use

cell.row
cell.column

and

cell.value=x
0
 
LVL 4

Accepted Solution

by:
yuppydu earned 1920 total points
ID: 39663274
Is this what you need?
Sub Get_GQnumber1()
    Dim rng As Range, cell As Range
    Dim lc As Long
    Dim s As String, x As String
   
    With Worksheets("DRA Summary")
   
    lc = .Cells(3, Columns.Count).End(xlToLeft).Column

    Set rng = .Range(.Cells(3, 1), .Cells(3, lc))
       
    For Each cell In rng
        If cell.Value Like "GQ-*" Then
            MsgBox cell.Value
            s = Left(cell.Value, InStr(1, cell.Value & " ", " ") - 1)
'A1 - When the "cell.Value" in the "DRA Summary" sheet is found then get it's Row and Column position

            On Error Resume Next
                       
            x = Application.VLookup(s, Worksheets("Data").Range("A:XFD"), 5, 0)
           
'Put the value x from the "Data" sheet acquired by the line...
'    "x = Application.VLookup(s, Worksheets("Data").Range("A:XFD"), 5, 0"
'to the postion found (specified comment A1) which will be in the "DRA Summary" sheet one row above
            cell.Offset(-1, 0) = x
        End If
    Next
    End With
End Sub
0
 

Author Comment

by:tesla764
ID: 39663305
I will try these suggestions now. I will let you know as soon as I test them.
Thanks.
0
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 
LVL 4

Expert Comment

by:yuppydu
ID: 39663309
BTW format your code, it is easier to read

Sub Get_GQnumber1()
    Dim rng As Range, cell As Range
    Dim lc As Long
    Dim s As String, x As String

    With Worksheets("DRA Summary")

        lc = .Cells(3, Columns.Count).End(xlToLeft).Column

        Set rng = .Range(.Cells(3, 1), .Cells(3, lc))

        For Each cell In rng
            If cell.Value Like "GQ-*" Then
                MsgBox cell.Value
                s = Left(cell.Value, InStr(1, cell.Value & " ", " ") - 1)

                On Error Resume Next

                x = Application.VLookup(s, Worksheets("Data").Range("A:XFD"), 5, 0)

                cell.Offset(-1, 0) = x
            End If
        Next
    End With
End Sub
0
 

Author Closing Comment

by:tesla764
ID: 39663360
Yuppydu, Thanks a billion. Looks like that works upon initial testing. Now we can move on. Kudos to you. You should have 480 points. I gave 20 to ssaqibh for participating. Which was the best way the system allowed me to share them.
Thank you to ssaqibh also your suggestion was appreciated.
Have a great day everybody.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39663398
You really do not have to give points for participating. The correct answer deserves full points and you should not deprive it of them.

Actually I had missed the part which said "one row above"
0
 
LVL 4

Expert Comment

by:yuppydu
ID: 39663443
Thanks, good day to you as well.
I have one question for you: why do you have a module for each sub?
Yuppydu
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
Microsoft has changed the look and feel of Azure AD and Microsoft account sign-in pages so that you will have a more unified look and feel when moving between the two interfaces.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

649 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