ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   use VB code IF to automate filling in 11 columns (https://www.excelbanter.com/excel-discussion-misc-queries/91134-use-vbulletin-code-if-automate-filling-11-columns.html)

smart.daisy

use VB code IF to automate filling in 11 columns
 
I used belowed VB code IF to automate fill in 11 columns:

If Cells(p, "D").Value = DateValue("01/01/2005") Then
a = Cells(p, "H").Value
b = Cells(p, "A").Value
............

The first ten work pretty well, but the last one, 11 one fails. Is it the
reason that IF in VB only allows ten variance? Thanks.



Nick Hodge

use VB code IF to automate filling in 11 columns
 
Use a Select Case statement instead (Psuedo code)

Select Case Cells(p, "D").Value
Case Is = 'Conditions here
'More Case Statements
Case Else
End Select

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HIS


"smart.daisy" wrote in message
...
I used belowed VB code IF to automate fill in 11 columns:

If Cells(p, "D").Value = DateValue("01/01/2005") Then
a = Cells(p, "H").Value
b = Cells(p, "A").Value
............

The first ten work pretty well, but the last one, 11 one fails. Is it the
reason that IF in VB only allows ten variance? Thanks.






All times are GMT +1. The time now is 02:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com