Loop not working properly

R

Rpettis31

I am trying to compare an item list to another sheet which contains a
multiplier.
So on sheet 1 ("data") if Item A is on Sheet 2 ("multiplier") then I look at
the multiplier column.
I then take this multiply factor times the quantities on the sheet 1 ("data")

For some reason this is not working and I am not sure why?

Dim MM As Integer
Dim MF As Integer
Dim MFactor As Integer

MM = 2

For Multi = 2 To 871

If Sheets("Data").Cells(Multi, 3) = Sheets("Multiplier").Cells(MM, 1) Then

MFactor = Sheets("Multiplier").Cells(MM, 3)

For MF = 15 To 27
Sheets("Data").Cells(Multi, MF) = Sheets("Data").Cells(Multi,
MF) * MFactor
Next MF

MM = MM + 1
End If

Next Multi
 
J

JLGWhiz

If I read your code correctly, you are attempting to match a value in column
C of Sheet 'data' to a value on the same row number in Column A of Sheet
'Multiplier". Then, if those two match, use the value in Column C of
'multiplier' as a multiplier to create a value starting in cell O2 of 'data'
and going thru AA2. I am going to assume that this last part is your problem
and that you do not really want to list the same value thirteen times for
each match. Unless you have existing values in columns O thru AA, you will
end up with zeros since anything times zero is zero.

I cannot really determine what you expect to happen, but what you should do
is use function key F8 to walk through your code line by line. Move your
mouse over the variables that you are using for cell references and see if
they are the ones you really want to use. If you can get the cell references
straightened out, then you can probably get the code to work. If not, post
back and try to give a little better explanation of what you want to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top