LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 295
Default Private sub causes too much screen jumping

I have code in a worksheet to expand the next column when an entry is made,
or to contract the column when an entry is deleted. It all works properly,
but every time the entry in (say) "H34" changes and the macro expands COLUMN
"J" it also checks through all of the others (there'll be 40 in all, so it's
quite tiresome to watch). Furthermore every time I enter data into any cell
on the sheet it goes through its checking routine. How can I get it to do
just the one next column when "H34" changes, and not do its check when I
enter data in other cells?

By the way, my preference was actually to hide/unhide the next column, but
that was way too jumpy. I then changed it to just shrink the column right
down but it's still not good to watch and use.

A sample of the code is as follows (there are 40 of these "With" statements)

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If Range("H34") "0" Then
Columns("I").ColumnWidth = 25
ElseIf Range("H34") < "1" Then
Columns("I").ColumnWidth = 0.5
End If
End With

With Target
If Range("I34") "0" Then
Columns("J").ColumnWidth = 25
ElseIf Range("I34") < "1" Then
Columns("J").ColumnWidth = 0.5
End If
End With

Thankyou for your time and brain.
Regards, Brett.
 
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
Private Sub Workbook_Open() doesn't run Steve Starr Excel Discussion (Misc queries) 4 April 3rd 11 05:05 AM
Private Sub CommandButton1_Click() Bob Excel Discussion (Misc queries) 2 December 2nd 06 02:14 AM
Removal of Private Information PosseJohn Excel Discussion (Misc queries) 4 November 27th 05 10:33 PM
Common Private Sub Booker Excel Discussion (Misc queries) 1 November 15th 05 08:50 AM
Private sub Mark New Users to Excel 3 April 6th 05 03:36 PM


All times are GMT +1. The time now is 10:55 AM.

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

About Us

"It's about Microsoft Excel"