Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Please could some-one give me the If structure to use for VB. Something very trivial such as if cell 0<ag4<=25 do a4*3 else if ag425 do a4*10 else do nothing end I would like to get the structure then I can try and build the rest of code. Thanks LiAD |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub Macro1()
Dim varTemp As Variant varTemp = Range("AG4") If varTemp 0 And varTemp <= 25 Then MsgBox varTemp * 3 ElseIf varTemp 25 Then MsgBox varTemp * 10 End If End Sub If this post helps click Yes --------------- Jacob Skaria "LiAD" wrote: Hi, Please could some-one give me the If structure to use for VB. Something very trivial such as if cell 0<ag4<=25 do a4*3 else if ag425 do a4*10 else do nothing end I would like to get the structure then I can try and build the rest of code. Thanks LiAD |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Thanks for this. When i try to combine this with an autofill code I'm getting a 1004 error - autofill method of range class failed, its fails on this line: Range("P217:AC218").AutoFill Destination:=Range("P217:AC" & lnglastRow) of this code: Sub Deletemeveryquickly() Dim varTemp As Variant varTemp = Range("AF4") If varTemp 0 And varTemp <= 25 Then Dim lnglastRow As Long lnglastRow = ActiveSheet.Range("C217").End(xlDown).Row If lnglastRow 265 Then lnglastRow = 265 Range("P217:AC218").AutoFill Destination:=Range("P217:AC" & lnglastRow) ElseIf varTemp 25 Then MsgBox varTemp * 10 End If End Sub Any ideas why that would be failing there? Thanks LiAD "Jacob Skaria" wrote: Sub Macro1() Dim varTemp As Variant varTemp = Range("AG4") If varTemp 0 And varTemp <= 25 Then MsgBox varTemp * 3 ElseIf varTemp 25 Then MsgBox varTemp * 10 End If End Sub If this post helps click Yes --------------- Jacob Skaria "LiAD" wrote: Hi, Please could some-one give me the If structure to use for VB. Something very trivial such as if cell 0<ag4<=25 do a4*3 else if ag425 do a4*10 else do nothing end I would like to get the structure then I can try and build the rest of code. Thanks LiAD |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It should be
Range("P217:AC217").AutoFill Destination:=Range("P217:AC" & lnglastRow) instead of Range("P217:AC218").AutoFill Destination:=Range("P217:AC" & lnglastRow) Also check out the value of lngLastRow.. If this post helps click Yes --------------- Jacob Skaria "LiAD" wrote: Hi, Thanks for this. When i try to combine this with an autofill code I'm getting a 1004 error - autofill method of range class failed, its fails on this line: Range("P217:AC218").AutoFill Destination:=Range("P217:AC" & lnglastRow) of this code: Sub Deletemeveryquickly() Dim varTemp As Variant varTemp = Range("AF4") If varTemp 0 And varTemp <= 25 Then Dim lnglastRow As Long lnglastRow = ActiveSheet.Range("C217").End(xlDown).Row If lnglastRow 265 Then lnglastRow = 265 Range("P217:AC218").AutoFill Destination:=Range("P217:AC" & lnglastRow) ElseIf varTemp 25 Then MsgBox varTemp * 10 End If End Sub Any ideas why that would be failing there? Thanks LiAD "Jacob Skaria" wrote: Sub Macro1() Dim varTemp As Variant varTemp = Range("AG4") If varTemp 0 And varTemp <= 25 Then MsgBox varTemp * 3 ElseIf varTemp 25 Then MsgBox varTemp * 10 End If End Sub If this post helps click Yes --------------- Jacob Skaria "LiAD" wrote: Hi, Please could some-one give me the If structure to use for VB. Something very trivial such as if cell 0<ag4<=25 do a4*3 else if ag425 do a4*10 else do nothing end I would like to get the structure then I can try and build the rest of code. Thanks LiAD |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() LiAD;470320 Wrote: Hi, Please could some-one give me the If structure to use for VB. Something very trivial such as if cell 0<ag4<=25 do a4*3 else if ag425 do a4*10 else do nothing end I would like to get the structure then I can try and build the rest of code. Thanks LiAD or:Sub blah() Select Case Range("AG4") Case Is 25 x = Range("A4") * 10 Case Is 0 x = Range("A4") * 3 End Select End Sub -- p45cal *p45cal* ------------------------------------------------------------------------ p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=129979 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
vba structure | Excel Programming | |||
what loop structure??? | Excel Programming | |||
Help with formula structure | Excel Discussion (Misc queries) | |||
if structure help | Excel Programming | |||
Structure of If...Else in VBA | Excel Programming |