I have a spreadsheet that is imported daily into an access database. The spreadsheets columns are always the same, however the number of rows will change daily. The spreadsheet represents invoices from the previous day.
What I need to do is check each row to see if a particular location in the field ordered one of about 28 parts. If so, I need to concatenate an "-A" on the end of the part number.
I started this, however, it doesn't work - I get a '1004' error - and even if it did work, it returns EVERY row. Is there a way to just have the macro check rows that contain data?
In the section above, I use Cells(j + 1, 7)
j+1 is to get past the first row (heading).
The 7 and 11 values are for PartNumber and Location (column G and K)
If I could get the IF statement above working properly, I was planning on just using a series of IF's to walk all 28 parts - I am sure there is a more efficient way to do this, but I don't know how... (perhaps use SQL - IF NOT IN (Part#1, Part#2, Part#3, etc.)??
Thanks for any help or suggestions
What I need to do is check each row to see if a particular location in the field ordered one of about 28 parts. If so, I need to concatenate an "-A" on the end of the part number.
I started this, however, it doesn't work - I get a '1004' error - and even if it did work, it returns EVERY row. Is there a way to just have the macro check rows that contain data?
Code:
Sub test()
'
Dim j
For j = 1 To Rows.Count
If Sheets("import").Cells(j + 1, 7).Value = "FK4DNF005000" And
Sheets("import").Cells(j + 1, 11).Value = "8603" Then
Sheets("import").Cells(j + 1, 7).Value = "FK4DNF005000-A"
End If
Next j
End Sub
In the section above, I use Cells(j + 1, 7)
j+1 is to get past the first row (heading).
The 7 and 11 values are for PartNumber and Location (column G and K)
If I could get the IF statement above working properly, I was planning on just using a series of IF's to walk all 28 parts - I am sure there is a more efficient way to do this, but I don't know how... (perhaps use SQL - IF NOT IN (Part#1, Part#2, Part#3, etc.)??
Thanks for any help or suggestions