View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Matt_2K[_2_] Matt_2K[_2_] is offline
external usenet poster
 
Posts: 1
Default Macro VBA, Drop down IF statement


Code
-------------------

Sub DropDown1_Change()
'
' DropDown1_Change Macro
' Macro recorded 02/11/2005 by 96bst01
If C4 = "1" Then
Range("E4").Select
Selection.NumberFormat = "0%"
ElseIf C4 = "2" Then
Range("E4").Select
Selection.NumberFormat = "£#,##0.00"
End If

End Sub

-------------------


I've got a spreadsheet, it has an ID, either 1 or 2, in cell C4. Thi
is changes when I change my dropdown (These are linked up to anothe
table, with ID 1 and 2).

I'm trying to say, if the value in C4 is 1, format E4 to a percentage
Else if the value in C4 is 2, I want it to format as currency.

As I am a programmer myself, mainly PHP, nothing like this,
understand the structure and know how to debug things. I think th
problem is coming from it not understanding what C4 is. Do I need t
define it?

Thanks

--
Matt_2
-----------------------------------------------------------------------
Matt_2K's Profile: http://www.excelforum.com/member.php...nfo&userid=617
View this thread: http://www.excelforum.com/showthread.php?threadid=48102