ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   I need Help With Range Command (https://www.excelbanter.com/excel-programming/366767-i-need-help-range-command.html)

Dan Thompson

I need Help With Range Command
 
Hi All,
Ok I am using the Range command to select multiple columns like this..

Range("A:A,B:B,C:C,F:F,AB:AB,AC:AC,BF:BF").Select

The problem I am having is my actual range of columns includes many more
columns that the example above.

Is there a maximum to how man columns you can include to select with the
range command ?
because the range command fails when I get to man coluns listed like say 200
or more.
Is there another way to accomplish this ? because all I realy want to do is
have vba do the same thing as if I manual selected up to 200 columns with the
mouse while holding down the Ctrl button.

Jim Jackson

I need Help With Range Command
 
If you are copying certain columns to paste in another workbook you might
consider hiding the unwanted columns.

Columns("D:E").visible = false
Columns("G:AA").visible=false

etc.

then you can have Range("A1:DF3000").select
Selection.copy

The only columns copied will be the visible ones.

Jim


"Dan Thompson" wrote:

Hi All,
Ok I am using the Range command to select multiple columns like this..

Range("A:A,B:B,C:C,F:F,AB:AB,AC:AC,BF:BF").Select

The problem I am having is my actual range of columns includes many more
columns that the example above.

Is there a maximum to how man columns you can include to select with the
range command ?
because the range command fails when I get to man coluns listed like say 200
or more.
Is there another way to accomplish this ? because all I realy want to do is
have vba do the same thing as if I manual selected up to 200 columns with the
mouse while holding down the Ctrl button.


Dan Thompson

I need Help With Range Command
 
Thanks for the help Jim, however allthough the "visible=false" was a good Idea
unfortunitly it will not work for what I need to do.

You see basicly what I am doing is I have a working code that takes chart
series values and locates them in there corisponding spread sheet. The
problem is that I want to delete all of irrelavent data columns in the same
spread sheet, thus only leaving the cloumns that are linked to data series on
my chart.
however when I use the Range("A:A,B:B,F:F.... ect ..ect ) command it doesn't
work once I get too man columns listed I think I can get up to "AF" and than
the range command seems to run out of gas and goes dumb (Excel VBA just
ignors that line all together).

I thought of trying to do this with using the column command but havent
been able to get that to work etiher.

Any more thoughts Anyone ?


"Jim Jackson" wrote:

If you are copying certain columns to paste in another workbook you might
consider hiding the unwanted columns.

Columns("D:E").visible = false
Columns("G:AA").visible=false

etc.

then you can have Range("A1:DF3000").select
Selection.copy

The only columns copied will be the visible ones.

Jim


"Dan Thompson" wrote:

Hi All,
Ok I am using the Range command to select multiple columns like this..

Range("A:A,B:B,C:C,F:F,AB:AB,AC:AC,BF:BF").Select

The problem I am having is my actual range of columns includes many more
columns that the example above.

Is there a maximum to how man columns you can include to select with the
range command ?
because the range command fails when I get to man coluns listed like say 200
or more.
Is there another way to accomplish this ? because all I realy want to do is
have vba do the same thing as if I manual selected up to 200 columns with the
mouse while holding down the Ctrl button.



All times are GMT +1. The time now is 02:56 AM.

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