+ Reply to Thread
Results 1 to 2 of 2

comparing text with macro

  1. #1
    Michael A
    Guest

    comparing text with macro

    ok, so i have been at this for awhile, I think my issue might be im trying to
    compare only numbers, and some of the things i am trying to compare are text.
    anyone that could help me correct this would be greatly appreciated..

    --
    Option Explicit

    Sub put_next_to_list()
    Dim rng As Range
    Dim r1 As Long
    Dim r2 As Long
    Dim r3 As Long
    Dim cell As Variant
    Dim FR As Long 'first row
    Dim LR As Long 'last row
    Dim i As Long
    Dim ssh As Object 'source sheet
    Dim tsh As Object 'target sheet

    Set ssh = Sheets(9)
    Set tsh = Sheets(10)

    FR = 1
    LR = tsh.Cells(65536, 1).End(xlUp).Row
    Set rng = tsh.Range(tsh.Cells(FR, 1), tsh.Cells(LR, 1))

    For Each cell In rng
    On Error Resume Next
    r1 = 0: r2 = 0: r3 = 0
    r1 = ssh.Columns(1).Find(cell.Offset(0, 0)).Row
    r2 = ssh.Columns(2).Find(cell.Offset(0, 1)).Row
    r3 = ssh.Columns(3).Find(cell.Offset(0, 2)).Row
    If r1 = 0 Or r1 <> r2 Or r1 <> r3 Then
    Else: cell.Offset(0, 6) = ssh.Cells(r1, 7)
    End If
    Next cell
    End Sub



  2. #2
    Dave Peterson
    Guest

    Re: comparing text with macro

    See one response at your other thread.

    Michael A wrote:
    >
    > ok, so i have been at this for awhile, I think my issue might be im trying to
    > compare only numbers, and some of the things i am trying to compare are text.
    > anyone that could help me correct this would be greatly appreciated..
    >
    > --
    > Option Explicit
    >
    > Sub put_next_to_list()
    > Dim rng As Range
    > Dim r1 As Long
    > Dim r2 As Long
    > Dim r3 As Long
    > Dim cell As Variant
    > Dim FR As Long 'first row
    > Dim LR As Long 'last row
    > Dim i As Long
    > Dim ssh As Object 'source sheet
    > Dim tsh As Object 'target sheet
    >
    > Set ssh = Sheets(9)
    > Set tsh = Sheets(10)
    >
    > FR = 1
    > LR = tsh.Cells(65536, 1).End(xlUp).Row
    > Set rng = tsh.Range(tsh.Cells(FR, 1), tsh.Cells(LR, 1))
    >
    > For Each cell In rng
    > On Error Resume Next
    > r1 = 0: r2 = 0: r3 = 0
    > r1 = ssh.Columns(1).Find(cell.Offset(0, 0)).Row
    > r2 = ssh.Columns(2).Find(cell.Offset(0, 1)).Row
    > r3 = ssh.Columns(3).Find(cell.Offset(0, 2)).Row
    > If r1 = 0 Or r1 <> r2 Or r1 <> r3 Then
    > Else: cell.Offset(0, 6) = ssh.Cells(r1, 7)
    > End If
    > Next cell
    > End Sub


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1