Hi all
I've tried this a multitude of ways and none work. My assignment is to take one text value in A1 and search D for that value. I've been somewhat successful, except I'm doing it from my macro editor because I don't know Excel VBA well and can't seem to fudge it this time. I have trouble dimensioning correct variables plus much of it just doesn't work for me yet. I am constantly trying to use VBA and sometimes it actually works!
Scenario: Sheet1 has a column of records (they have leading zeros so their format is Text). For each of those records, I search a column in Sheet2. If it is found on Sheet2, notate the column to the right. Then go back to Sheet1, capture the next record, go to Sheet2, search for the record. Do this until all records in Sheet1 have gone to Sheet2 and searched the column.
I don't have VBA to send, but I can send an Attachmate macro code that sort of works but takes all day looping through the thousand records. the attachment field would not allow me to attach a document so I'm pasting it here.
Please help! Thanks so much!
'--------------------------------------------------------------------------
Sub Main()
Dim xl1 as Integer, xl2 as Integer, xl3 as Integer, RC, x
Dim xlIntId as string, i as Integer, fndIntId as String, tstver as string
'OPER WORKBOOK
Call GetExcel ()
'BEGIN WITH ROW 2 FOR ALL SHEETS
xl1 = 2 ' IntrlIds row number last used
xl2 = 2 ' FindId
xl3 = 2 ' PostRec row number last used
'LOOP THROUGH ALL IntrlIds
Do
'GET INTERNAL ID FROM IntrlIds SHEET
xlIntId = objWorkbook.Worksheets("IntrlIds").cells(xl1,1) Do
'GET FNDiNTID
fndIntId = Trim(objWorkbook.Worksheets("FindId").cells(xl2,21)) 'COUNTS THROUGH ALL FindId RECORDS
'COMPARE IDS
If (xlIntId = fndIntId) Then
'Call MvRec()
objWorkbook.Worksheets("FindId").cells(xl2,22) = fndIntId
objWorkbook.Worksheets("IntrlIds").cells(xl1,2)= "y"
xl2 = 2
goto nextacct
End if
xl2 = xl2 + 1
Loop until fndIntId = ""
If fndIntId = "" then
xl2 = 2
End if
NextAcct:
xl1 = xl1 + 1
xlIntId = objWorkbook.Worksheets("IntrlIds").cells(xl1,1)
Loop until xlIntId = ""
End Sub
I've tried this a multitude of ways and none work. My assignment is to take one text value in A1 and search D for that value. I've been somewhat successful, except I'm doing it from my macro editor because I don't know Excel VBA well and can't seem to fudge it this time. I have trouble dimensioning correct variables plus much of it just doesn't work for me yet. I am constantly trying to use VBA and sometimes it actually works!
Scenario: Sheet1 has a column of records (they have leading zeros so their format is Text). For each of those records, I search a column in Sheet2. If it is found on Sheet2, notate the column to the right. Then go back to Sheet1, capture the next record, go to Sheet2, search for the record. Do this until all records in Sheet1 have gone to Sheet2 and searched the column.
I don't have VBA to send, but I can send an Attachmate macro code that sort of works but takes all day looping through the thousand records. the attachment field would not allow me to attach a document so I'm pasting it here.
Please help! Thanks so much!
'--------------------------------------------------------------------------
Sub Main()
Dim xl1 as Integer, xl2 as Integer, xl3 as Integer, RC, x
Dim xlIntId as string, i as Integer, fndIntId as String, tstver as string
'OPER WORKBOOK
Call GetExcel ()
'BEGIN WITH ROW 2 FOR ALL SHEETS
xl1 = 2 ' IntrlIds row number last used
xl2 = 2 ' FindId
xl3 = 2 ' PostRec row number last used
'LOOP THROUGH ALL IntrlIds
Do
'GET INTERNAL ID FROM IntrlIds SHEET
xlIntId = objWorkbook.Worksheets("IntrlIds").cells(xl1,1) Do
'GET FNDiNTID
fndIntId = Trim(objWorkbook.Worksheets("FindId").cells(xl2,21)) 'COUNTS THROUGH ALL FindId RECORDS
'COMPARE IDS
If (xlIntId = fndIntId) Then
'Call MvRec()
objWorkbook.Worksheets("FindId").cells(xl2,22) = fndIntId
objWorkbook.Worksheets("IntrlIds").cells(xl1,2)= "y"
xl2 = 2
goto nextacct
End if
xl2 = xl2 + 1
Loop until fndIntId = ""
If fndIntId = "" then
xl2 = 2
End if
NextAcct:
xl1 = xl1 + 1
xlIntId = objWorkbook.Worksheets("IntrlIds").cells(xl1,1)
Loop until xlIntId = ""
End Sub