column selection in vba

aviadht

Board Regular
Joined
Aug 7, 2008
Messages
91
<TABLE class=tborder id=post2395995 cellSpacing=0 cellPadding=6 width="100%" align=center border=0><TBODY><TR vAlign=top><TD class=alt1 id=td_post_2395995 style="BORDER-RIGHT: #ffffff 1px solid">I want to select columns with parameters

parameter 1: col1
parameter 2:col2

and the next one not working: columns(col1,col2).select

why ?

Aviad
<!-- / message --></TD></TR><TR><TD class=alt2 style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 0px solid; BORDER-LEFT: #ffffff 1px solid; BORDER-BOTTOM: #ffffff 1px solid">
user_online.gif
</TD><TD class=alt1 style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 0px solid; BORDER-LEFT: #ffffff 0px solid; BORDER-BOTTOM: #ffffff 1px solid" align=right><!-- controls -->
progress.gif
</TD></TR></TBODY></TABLE>
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Its rarely necessary to select.

But here you go:

Code:
Sub test()
Dim col1 As Long, col2 As Long
col1 = 5: col2 = 17
Range(Columns(col1), Columns(col2)).Select
End Sub
 
Upvote 0
ok, thank you..it works..but now i have another question (-:

asume that i'm on activecell and i want the parameter (integer) "colnum" to get te activecell column number. for example column b number is 2.

how can i do that ?

Regards,
Aviad
 
Upvote 0
Code:
Sub test()
Dim col1 As Long, col2 As Long
col1 = ActiveCell.Column: col2 = 17
Range(Columns(col1), Columns(col2)).Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,384
Members
448,956
Latest member
JPav

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top