Translate # to word & print

Closed
HM - Apr 24, 2010 at 01:24 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Apr 24, 2010 at 02:34 PM
Hi,
I am trying to write a code to get the number (1,2,3,etc.) out of a column (G to be specific), translate that number to category (1=Savings), then print that category in the adjecent cell (column h). To clarifiy, if G2=1, type "Savings" in H2. I have tried several different methods but it has been a long time since I used vba and my skills appear to have faded! I started trying to use "Select Case" and defaulted back to multiple "If" statements. I totally screwed myself with a "Do" loop and now I am just plain frustrated.
My code is below. Can you see what I have done wrong?
THX

Sub category()

If ActiveCell.Select = 1 Then
ActiveCell.Offset(0, 1).Select = "Savings"
End If

If ActiveCell.Select = 2 Then
ActiveCell.Offset(0, 1).Select = "Grocercies"
End If

If ActiveCell.Select = 3 Then
ActiveCell.Offset(0, 1).Select = "CASH"
End If

If ActiveCell.Select = 4 Then
ActiveCell.Offset(0, 1).Select = "Medical"
End If

If ActiveCell.Select = 5 Then
ActiveCell.Offset(0, 1).Select = "Lucy / Harley"
End If

If ActiveCell.Select = 6 Then
ActiveCell.Offset(0, 1).Select = "Miscellaneous"
End If

If ActiveCell.Select = 7 Then
ActiveCell.Offset(0, 1).Select = "Eating Out"
End If

If ActiveCell.Select = 8 Then
ActiveCell.Offset(0, 1).Select = "Sporting Events"
End If

If ActiveCell.Select = 9 Then
ActiveCell.Offset(0, 1).Select = "Home Shopping"
End If

If ActiveCell.Select = 10 Then
ActiveCell.Offset(0, 1).Select = "Will be Returned - John"
End If

If ActiveCell.Select = 11 Then
ActiveCell.Offset(0, 1).Select = "Gas"
End If

If ActiveCell.Select = 12 Then
ActiveCell.Offset(0, 1).Select = "Hailey's Paycheck"
End If

If ActiveCell.Select = 13 Then
ActiveCell.Offset(0, 1).Select = "JOHN???"
End If

If ActiveCell.Select = 14 Then
ActiveCell.Offset(0, 1).Select = "Personal Shopping"
End If

If ActiveCell.Select = 15 Then
ActiveCell.Offset(0, 1).Select = "Gifts"
End If

If ActiveCell.Select = 16 Then
ActiveCell.Offset(0, 1).Select = "Vehicle Maintenance"
End If

ActiveCell.Offset(1,-1).Select

End Sub

Related:

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Apr 24, 2010 at 02:34 PM
These sort of lines

ActiveCell.Offset(0, 1).Select = "Savings"

there is no select when you are assigning it a value
you want

ActiveCell.Offset(0, 1).value= "Savings"
or simply
ActiveCell.Offset(0, 1)= "Savings"