Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting Columns

On Feb 25, 6:38*am, "Mike Fogleman" wrote:
Sub test()
Dim i As Long
Dim numcolumn As Long
numcolumn = Range("J2")
'Column AC is 18 columns from K
For i = 18 To numcolumn Step -1
Columns("K:K").Offset(0, i).Delete
Next

End Sub

Mike F

"Simon Lloyd" wrote in message

...





This should do what you need
Dim i As Long
Dim numcolumn As Long
numcolumn = Range("J2")
For i = numcolumn To 1 Step -1
Columns("K:K").Offset(0, i).Delete
Next ;244984 Wrote:
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!


--
Simon Lloyd


Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile:
http://www.thecodecage.com/forumz/member.php?userid=1
View this thread:http://www.thecodecage.com/forumz/sh...d.php?t=68330- Hide quoted text -


- Show quoted text -


Thank you very much to everyone for their help. All the solutions have
worked and I'm grateful for the assistance.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting Columns [email protected][_2_] Excel Programming 1 February 24th 09 11:31 PM
Selecting columns PaulaO Excel Programming 2 March 6th 06 08:23 PM
Selecting Columns Shatin[_2_] Excel Programming 4 September 7th 05 01:07 PM
Selecting columns aspadda Excel Programming 1 December 9th 03 03:56 AM
Selecting Columns xnman Excel Programming 2 November 18th 03 01:52 PM


All times are GMT +1. The time now is 10:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"