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


You would need to loop the command. This will loop through the comman
until there is no longer a value in column C.

Sub test()
Dim i As Integer

i = 1

Do While Cells(i, 3).Value "0"

If cells(i, 3).Value = "1" Then
cells(i, 5).Select
Selection.NumberFormat = "0%"
ElseIf cells(i, 3).Value = "2" Then
cells(i, 5).Select
Selection.NumberFormat = "£#,##0.00"
End If

i = i + 1

Loop
End Sub

Matt_2K Wrote:
Thanks. I modified my code a bit using this:


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

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

End Sub

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


Now, this code works fine for one row, but can I have this o
multiple rows?

E.g. having a drop down box which is linked to a cell reference, BU
i need the C4 and E4 to change depending on the row and cell link
How can I achieve this in VBA


--
dok11
-----------------------------------------------------------------------
dok112's Profile: http://www.excelforum.com/member.php...fo&userid=1058
View this thread: http://www.excelforum.com/showthread.php?threadid=48102