Change code by code. Can you do that?

C

Corey

LastCell = Worksheets("Main").Cells(Rows.Count, "B").End(xlUp).Row ' CHANGE COLUMN (B) TO (D) FOR
YEAR-2008

With the above line of code,
If the date which is input (Now, Format "mmmm yy") into sheet1.range("C16") when the workbook opens
the year changes from 2007 to 2008,
then the above code line "B" changes to "D".


Can vb do this?

Corey.....
 
M

merjet

iYr = Year(Sheets("Sheet1").Range("C16")
If iYr = 2007 Then aCol = "B"
If iYr = 2008 Then aCol = "D"
LastCell = Worksheets("Main").Cells(Rows.Count, aCol).End(xlUp).Row

Merjet
 
C

Corey

Thank you Merjet



iYr = Year(Sheets("Sheet1").Range("C16")
If iYr = 2007 Then aCol = "B"
If iYr = 2008 Then aCol = "D"
LastCell = Worksheets("Main").Cells(Rows.Count, aCol).End(xlUp).Row

Merjet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top