please proof read vba code:

spcalan

Well-known Member
Joined
Jun 4, 2008
Messages
1,247
Please proof read me code.
it works, but it seems to miss over half the data I need to extract.
Strange.

Sub trial()
x = 1
y = 2

lr = Sheets("charge report").Cells(Rows.Count, "A").End(xlUp).Row

Do Until x > lr
Do Until Left(Sheets("charge report").Cells(x, 10), 1) = "S" AndLen(Sheets("charge report").Cells(x, 10)) = 7 Or x > lr
x = x + 1
Loop
invoice = (Sheets("charge report").Cells(x, 10)) & (Sheets("charge report").Cells(x, 11))
'MsgBox ("Your Invoice number is ") & invoice

Do Until Left(Sheets("charge report").Cells(x, 11), 1) = "Q" Or x > lr
x = x + 1
Loop

'MsgBox x


Row = x
pcode = (Sheets("charge report").Cells(x, 3))
desc = (Sheets("charge report").Cells(x, 4))
lot# = (Sheets("charge report").Cells(x + 1, 9))
chcode = (Sheets("charge report").Cells(x, 11))

'MsgBox Row
'MsgBox pcode
'MsgBox desc
'MsgBox lot#
'MsgBox chcode

'Paste Extracted Data into "Data" Sheet

Sheets("data").Cells(y, 1) = invoice
Sheets("data").Cells(y, 2) = Row
Sheets("data").Cells(y, 3) = pcode
Sheets("data").Cells(y, 4) = desc
Sheets("data").Cells(y, 5) = lot#
Sheets("data").Cells(y, 6) = chcode


x = x + 1
y = y + 1

Loop
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Please describe what you are aiming for this code to do. I want to hear it in English rather than having to infer your intent from your code ( especially as the code doesn't do what you want ).
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,509
Members
448,967
Latest member
screechyboy79

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top