using if statement in excel VBA variable
Posted on 2013-05-15
I have reached the bounds of my limited capability and could do with some assistance with my excel VBA
I am wanting to assess a variable 'ProjectTo' with an if statement.
My VBA currently takes values from specified cells in an active sheet and subsequently passes these to an SQL string, which is all working fine.
Dim ProjectTo As String
Dim ProjecTFrom As String
ProjectFrom = ActiveSheet.Range("C16").Value
ProjectTo = ActiveSheet.Range("C17").Value
For the 'ProjectTo' I would like to use an IF statement, along the line of "if the cell contents 'C17' is empty then use a hardcoded value of say '999999' else use the cells contents"
I have tried inserting IF statements into the above (current state) however receive error messages that I am unable to get past and therefore need some expert assistance please.