PC Review


Reply
Thread Tools Rate Thread

Columns other than one selected by macro being erroneously selecte

 
 
MichaelDavid
Guest
Posts: n/a
 
      17th Jul 2009
Greetings! I would like to select column H on a worksheet so that I can
search for specified values in Column H. When I click on the column H Header
("H" at the top of the worksheet), all of column H is selected as expected.

I then wrote the following macro to select Column H:

Sub FindCloseDate()

' FindCloseDate Macro

' Keyboard Shortcut: Ctrl+l

Columns("H:H").Select


End Sub

When I execute this macro, all of columns A through O are selected. The
worksheet is somewhat irregular in that I believe it contains some merged
cells. I am not sure how to include the actual worksheet in this post. I
would like some way of simulating, via an Excel macro, the manual selection
of column H on the worksheet such that only column H is selected. Any help or
suggestions will be greatly appreciated.

--

May you have a most blessed day!

Sincerely,

Michael Fitzpatrick

 
Reply With Quote
 
 
 
 
marcus
Guest
Posts: n/a
 
      17th Jul 2009
Hi Michael

It would appear that your merged cells run right through column H.
This is why so many columns are selected. Most likely it is at the
headings in ROW 1 where this is happening so, assuming your merged
cells occur in Row 1 the following will highlight all the used cells
from H2 to the bottom of your dataset.

Sub SelColH()
Dim lw As Integer
lw = Range("H" & Rows.Count).End(xlUp).Row
Range("H2:H" & lw).Select
End Sub


If in the middle of your dataset, you have a heap of merged cells that
run through Column H then I suggest you unmerge those cells. You can
almost always replicate the appearance of merged Cells without
merging.

Hope this helps.

Marcus

 
Reply With Quote
 
MichaelDavid
Guest
Posts: n/a
 
      17th Jul 2009
Greetings! Thanks a million! That's it!!!

Columns("H:H").UnMerge
Columns("H:H").Select

With this solution, it matters not what nor where merged cells are.
--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick


"marcus" wrote:

> Hi Michael
>
> It would appear that your merged cells run right through column H.
> This is why so many columns are selected. Most likely it is at the
> headings in ROW 1 where this is happening so, assuming your merged
> cells occur in Row 1 the following will highlight all the used cells
> from H2 to the bottom of your dataset.
>
> Sub SelColH()
> Dim lw As Integer
> lw = Range("H" & Rows.Count).End(xlUp).Row
> Range("H2:H" & lw).Select
> End Sub
>
>
> If in the middle of your dataset, you have a heap of merged cells that
> run through Column H then I suggest you unmerge those cells. You can
> almost always replicate the appearance of merged Cells without
> merging.
>
> Hope this helps.
>
> Marcus
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple cells or columns are selected instead of selected cell or Mikey Microsoft Excel Misc 1 29th Apr 2009 09:48 PM
Using VBA macro - how to just chart two selected columns RLExcelUserTS Microsoft Excel Programming 0 27th Mar 2006 05:02 PM
A recorded Macro to hide certain selected columns hides non selec. =?Utf-8?B?TWxtb3R0ZXI=?= Microsoft Excel Programming 2 31st Dec 2004 02:56 PM
Macro to unhide selected columns & rows Brian Belliveau Microsoft Excel Discussion 2 15th Dec 2003 01:26 PM
check for selected columns in a macro =?Utf-8?B?cGhpbGlwIHdhdHNvbg==?= Microsoft Excel Programming 1 2nd Dec 2003 09:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:48 AM.