formual in macro

C

Chip Smith

i am having a problem rewriting the formula in my macro, i'm trying to
multiple the value of a cell that is to rows over to the right, however it
doesn't work as planned. any insight?

Private Sub cmdAdd_Click()
Dim Order As String
Dim Index As Variant
Dim nextrow As Long
Order = txtOrder.Value


With Range("K:K")
Set c = .Find(Order, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Cells(c.Row, 2).Value = Cells(c.Row, 2).Value + ((Me.txtShip.Value /
Me.txtPart.Value) * the value of a cell that is 2 rows to the right)

Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With

End Sub
 
P

PCLIVE

Cells(c.Row, 2).Value = Cells(c.Row, 2).Value + ((Me.txtShip.Value / _
Me.txtPart.Value) * Me.txtPart.Offset(0, 2).Value)
 
T

Tom Ogilvy

saying two rows to the right is a big ambiguous. To the right of what. Rows
go up and down, not right and left. Some possible interpretations:

two rows down from c.row
Cells(c.Row, 2).Value = Cells(c.Row, 2).Value + ((Me.txtShip.Value /
Me.txtPart.Value) * cells(c.row + 2, 2))

two columns to the right of c.column (column M)

Cells(c.Row, 2).Value = Cells(c.Row, 2).Value + ((Me.txtShip.Value /
Me.txtPart.Value) * cells(cell.row,cell.column + 2))

Column D (two columns to the right of column 2)

Cells(c.Row, 2).Value = Cells(c.Row, 2).Value + ((Me.txtShip.Value /
Me.txtPart.Value) * cells(c.row,4))
 
C

Chip Smith

i do apologize i meant to say columns, not rows. my mistake
--
--Chip Smith--



PCLIVE said:
Cells(c.Row, 2).Value = Cells(c.Row, 2).Value + ((Me.txtShip.Value / _
Me.txtPart.Value) * Me.txtPart.Offset(0, 2).Value)
 
T

Tom Ogilvy

Just a heads up to PCLive, but I don't think a textbox has an offset
property. Maybe you meant something else.

--
regards,
Tom Ogilvy


PCLIVE said:
Cells(c.Row, 2).Value = Cells(c.Row, 2).Value + ((Me.txtShip.Value / _
Me.txtPart.Value) * Me.txtPart.Offset(0, 2).Value)
 
P

PCLIVE

Thanks Tom. I overlooked the period thinking it was a variable. Sorry for
the confusion.

Tom Ogilvy said:
Just a heads up to PCLive, but I don't think a textbox has an offset
property. Maybe you meant something else.
 

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