shuco

12-11-2008, 06:43 PM

I am trying to make macro that looks at 3 cells on each row , determines what they are and fills a cell with a value until there are 4 continuious blank spaces.

ActiveCell would be from E2 until the end of the document.

In my code I will have values of HEALTH 1 , HEALTH 2 and HEALTH 3 G2 until the end of the document

N2 will have SN, SS, SD and FM until the end of the document.

This is what I have so far:

Sub macro()

Range("e2").Select

Do

If (ActiveCell = "00170016") Then

If (ActiveCell.Select.Offset(0, 9) = "SN") Then

Sheet1.Range("h2") = "$301"

End If

If (ActiveCell.Select.Offset(0, 9) = "SS") Then

Sheet1.Range(ActiveCell.Offset(0, 3)) = "$734.39"

End If

If (ActiveCell.Select.Offset(0, 9) = "SD") Then

Sheet1.Range(ActiveCell.Offset(0, 3)) = "$734.39"

End If

If (ActiveCell.Offset(0, 9) = "FM") Then

Sheet1.Range(ActiveCell.Offset(0, 3)) = "$1044.87"

End If

End If

If (ActiveCell = "00170017") Then

If (ActiveCell.Offset(0, 2) = "HEALTH 1") Then

If (ActiveCell.Offset(0, 9) = "SN") Then

ActiveCell.Offset(0, 3) = "$267.97"

End If

If (ActiveCell.Offset(0, 2) = "HEALTH 2") Then

If (ActiveCell.Offset(0, 9) = "SS") Then

ActiveCell.Offset(0, 3) = "$658.26"

End If

If (ActiveCell.Offset(0, 9) = "SD") Then

ActiveCell.Offset(0, 3) = "$658.26"

End If

If (ActiveCell.Offset(0, 9) = "FM") Then

ActiveCell.Offset(0, 3) = "$937.9"

End If

End If

If (ActiveCell.Offset(0, 2) = "HEALTH 3") Then

If (ActiveCell.Offset(0, 9) = "SN") Then

ActiveCell.Offset(0, 3) = "$217.6"

End If

If (ActiveCell.Offset(0, 9) = "SS") Then

ActiveCell.Offset(0, 3) = "$537.29"

End If

If (ActiveCell.Offset(0, 9) = "SD") Then

ActiveCell.Offset(0, 3) = "$537.29"

End If

If (ActiveCell.Offset(0, 9) = "FM") Then

ActiveCell.Offset(0, 3) = "$761.6"

End If

End If

End If

End If

ActiveCell.Offset(1, 0).Select

Loop Until IsEmpty(ActiveCell.Offset(1, 0))

End Sub

I am pretty new to VBA, but I have coded in php and c#

That said I am not sure the correct way to check a field by an offset of (0,2) etc...

Any Help would be GREAT!

ActiveCell would be from E2 until the end of the document.

In my code I will have values of HEALTH 1 , HEALTH 2 and HEALTH 3 G2 until the end of the document

N2 will have SN, SS, SD and FM until the end of the document.

This is what I have so far:

Sub macro()

Range("e2").Select

Do

If (ActiveCell = "00170016") Then

If (ActiveCell.Select.Offset(0, 9) = "SN") Then

Sheet1.Range("h2") = "$301"

End If

If (ActiveCell.Select.Offset(0, 9) = "SS") Then

Sheet1.Range(ActiveCell.Offset(0, 3)) = "$734.39"

End If

If (ActiveCell.Select.Offset(0, 9) = "SD") Then

Sheet1.Range(ActiveCell.Offset(0, 3)) = "$734.39"

End If

If (ActiveCell.Offset(0, 9) = "FM") Then

Sheet1.Range(ActiveCell.Offset(0, 3)) = "$1044.87"

End If

End If

If (ActiveCell = "00170017") Then

If (ActiveCell.Offset(0, 2) = "HEALTH 1") Then

If (ActiveCell.Offset(0, 9) = "SN") Then

ActiveCell.Offset(0, 3) = "$267.97"

End If

If (ActiveCell.Offset(0, 2) = "HEALTH 2") Then

If (ActiveCell.Offset(0, 9) = "SS") Then

ActiveCell.Offset(0, 3) = "$658.26"

End If

If (ActiveCell.Offset(0, 9) = "SD") Then

ActiveCell.Offset(0, 3) = "$658.26"

End If

If (ActiveCell.Offset(0, 9) = "FM") Then

ActiveCell.Offset(0, 3) = "$937.9"

End If

End If

If (ActiveCell.Offset(0, 2) = "HEALTH 3") Then

If (ActiveCell.Offset(0, 9) = "SN") Then

ActiveCell.Offset(0, 3) = "$217.6"

End If

If (ActiveCell.Offset(0, 9) = "SS") Then

ActiveCell.Offset(0, 3) = "$537.29"

End If

If (ActiveCell.Offset(0, 9) = "SD") Then

ActiveCell.Offset(0, 3) = "$537.29"

End If

If (ActiveCell.Offset(0, 9) = "FM") Then

ActiveCell.Offset(0, 3) = "$761.6"

End If

End If

End If

End If

ActiveCell.Offset(1, 0).Select

Loop Until IsEmpty(ActiveCell.Offset(1, 0))

End Sub

I am pretty new to VBA, but I have coded in php and c#

That said I am not sure the correct way to check a field by an offset of (0,2) etc...

Any Help would be GREAT!