ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change code by code. Can you do that? (https://www.excelbanter.com/excel-programming/384220-change-code-code-can-you-do.html)

Corey

Change code by code. Can you do that?
 
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.....



merjet

Change code by code. Can you do that?
 
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



Corey

Change code by code. Can you do that?
 
Thank you Merjet



"merjet" wrote in message
oups.com...
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





All times are GMT +1. The time now is 03:35 PM.

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