Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 22nd, 2004, 04:11 AM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default vb script + excel - select multiple columns

Hi everyone,
I am trying to set the autofilter property on for a group of
consecutive columns.


I guess this is done using:
excel_app.Selection.AutoFilter = True


The problem is with the selection of columns. The left top cell (E6) is
known but the right top cell has to be 10th from right (same row)


So, I have been trying code like:
excel_app.Range(Sheet.Cells(E, 6), Sheet.Cells(x, 6)).Select filling x
with different things, none of which seem to work.


Can anyone here suggest how to do this?


I am new to this, so kindly explain in terms of the following
variables:


Set excel_app = CreateObject("Excel.Application")
Set excel_wbk = excel_app.Workbooks.Open(fileName)
Set excel_wks = excel_wbk.Sheets(1)
Set pivotTable = excel_wks.PivotTables(1)
Thanks in advance for the help.

 
Old January 21st, 2005, 06:11 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: Bournemouth, Dorset, United Kingdom.
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To ascertain the tenth column from the right I would use something like this...

sub myProc()
    myCol = Range("IV6").End(xlToLeft).Column - 10
    Range("E6", Cells(6, myCol)).Select
    Selection.AutoFilter
end sub

I wouldn't bother even trying to get involved in the Set examples shown above because you would only normally use in real life the createobject code when trying to control excel from another office application such as word (called Automation).

Hope this has been helpful.

Cheers

Matthew




Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing Multiple Files Into Excel Using VB bsac Excel VBA 4 January 27th, 2014 11:37 AM
SELECT VARIABLE Number of columns drani Oracle 4 September 21st, 2008 01:12 AM
Select a value across 3 different columns jfergy Classic ASP Databases 0 January 23rd, 2006 02:46 AM
VB Script with Excel mateenmohd VB How-To 0 February 19th, 2005 06:33 AM
Copying Multiple Rows in MS Excel 2K using VB .Net Azhar Akbari Excel VBA 2 January 27th, 2005 10:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.