ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   I set up a macro to hide/unhide columns. It hides more columns (https://www.excelbanter.com/excel-programming/372276-i-set-up-macro-hide-unhide-columns-hides-more-columns.html)

Lori

I set up a macro to hide/unhide columns. It hides more columns
 
It is supposed to hide column J, copy column I, paste special (values) to
column J and re-hide column J. It does all that AND THEN hides columns G
through L instead of just J. I I have no idea how to correct.. Help... Lori
Sub Test()
'
' Test Macro
' Macro recorded 9/6/2006 by LORI MILLER
'
' Keyboard Shortcut: Ctrl+a
'
Columns("I:K").Select
Selection.EntireColumn.Hidden = False
Range("I11:I34").Select
Selection.Copy
Range("J11").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

'Hide Column J

Columns("J:J").Select

Selection.EntireColumn.Hidden = True

End Sub


Jim Thomlinson

I set up a macro to hide/unhide columns. It hides more columns
 
So long as you avoid the selects there is no need to unhide and hide.
Something like this...

Sub Test()
'
' Test Macro
' Macro recorded 9/6/2006 by LORI MILLER
'
' Keyboard Shortcut: Ctrl+a
'
Range("I11:I34").Copy
Range("J11").PasteSpecial Paste:=xlPasteValues
Application.cutcopymode = false
End Sub

--
HTH...

Jim Thomlinson


"Lori" wrote:

It is supposed to hide column J, copy column I, paste special (values) to
column J and re-hide column J. It does all that AND THEN hides columns G
through L instead of just J. I I have no idea how to correct.. Help... Lori
Sub Test()
'
' Test Macro
' Macro recorded 9/6/2006 by LORI MILLER
'
' Keyboard Shortcut: Ctrl+a
'
Columns("I:K").Select
Selection.EntireColumn.Hidden = False
Range("I11:I34").Select
Selection.Copy
Range("J11").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

'Hide Column J

Columns("J:J").Select

Selection.EntireColumn.Hidden = True

End Sub



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

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