Need help with if's in macro

YoyoZ

New Member
Joined
Aug 30, 2007
Messages
26
What i need is if "a" is placed in A1, then "Attack" is placed in B1, and if 'a' is place in A2, then "Attack" is placed in B2, and If 'p' is placed in A3, then "magic" in B3 and so on, Here what i have

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Range("B3:B30")) Is Nothing Then

Exit Sub
     
Else
        Select Case Target.Value
          Case "A"
               Run "RAttack"
          Case "P"
               Run "RMagic"
          Case "D"
               Run "RDefend"
          Case "R"
               Run "RmyRun"
     End Select
End If
End Sub


Sub RAttack()
If IsEmpty(Sheets("Sheet3").Range("C3")) Then
     Sheets("Sheet3").Range("C3").Value = "Attack"
Else
     Sheets("Sheet3").Range("C" & Rows.Count).End(xlUp).Offset(1).Value = "Attack"
End If
End Sub


Sub RMagic()
If IsEmpty(Sheets("Sheet3").Range("C3")) Then
     Sheets("Sheet3").Range("C3").Value = "Magic"
Else
     Sheets("Sheet3").Range("C" & Rows.Count).End(xlUp).Offset(1).Value = "Magic"
End If
End Sub


Sub RDefend()
If IsEmpty(Sheets("Sheet3").Range("C3")) Then
     Sheets("Sheet3").Range("C3").Value = "Defend"
Else
     Sheets("Sheet3").Range("C" & Rows.Count).End(xlUp).Offset(1).Value = "Defend"
End If
End Sub


Sub RmyRun()
If IsEmpty(Sheets("Sheet3").Range("C3")) Then
     Sheets("Sheet3").Range("C3").Value = "Run"
Else
     Sheets("Sheet3").Range("C" & Rows.Count).End(xlUp).Offset(1).Value = "Run"
End If
End Sub
 
Code:
Private Sub Worksheet_Change(ByVal Target As Range) 
If Intersect(Target, Range("a1:a10")) Is Nothing Then 
Exit Sub
Else
If IsEmpty(Sheets("Moves").Range("F3")) Then 
     Sheets("Moves").Range("F3").Value = Sheets("Multipliers").Range("E3") 
Else 
     Sheets("Moves").Range("F" & Rows.Count).End(xlUp).Offset(1).Value = Sheets("Multipliers").Range("E" & Rows.Count).End(xlUp)p
End Sub

the only bit wrong is
Code:
Sheets("Moves").Range("F" & Rows.Count).End(xlUp).Offset(1).Value = Sheets("Multipliers").Range("E" & Rows.Count).End(xlUp)
because Sheets("multipliers").Range("E" & Rows.Count) as already all got values in them. If someone could let me send them my file, then they mite understand......
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,215,056
Messages
6,122,907
Members
449,096
Latest member
dbomb1414

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