![]() |
Selecting Columns
Hi all!
I am trying to run a program which would allow me to do the following: I have a number that is put in Cell J2 by me or any other user. That number denotes the number of columns away from column K that I need to start deleting from; I will delete from there all the way up to column AC. So, fo rexample, I have the number 5 in cell J2. This would mean I need to start deleting from column P all the way to column AC. If the number is 3 in J2, then I would delete from column M to column AC. I don't know the method to select the columns based on the number. So far I have: NumColumn = Range("J2") Range("K2").Select ActiveCell.Offset(0,NumColumn) From this point on, I don't know how to select the column I'm in after the offset all the way to column AC. If someone can help with this, I would be forever grateful! Thanks in advance! |
Selecting Columns
I'm sure you will get other answers more directly related to using offset;
I'd do something like the following (just because it is what I know): NumColumn = Range("J2") CharColumn =(Asc(UCase(NumColumn )) - 64) Columns(CharColumn & ":AC").Select This is aircode, so it may need some tweaking... and it will only work up to a start column of Z; after that the CharColumn will give you ascii characters above Z (it won't automatically wrap back around to column 'AA'). HTH, Keith |
All times are GMT +1. The time now is 08:50 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com