ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   macro and deleting or hiding columns (https://www.excelbanter.com/excel-discussion-misc-queries/133885-macro-deleting-hiding-columns.html)

Pascale

macro and deleting or hiding columns
 
Hello
I have done very basic macros using "tools" and "record new macro". I need
to create one that will delete some columns and hide others. How can I do
this please?
Many thanks. I am working on excel 2003.

Bob Phillips

macro and deleting or hiding columns
 

Columns("H:J").Delete
Columns("M:O").Hidden = True

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Pascale" wrote in message
...
Hello
I have done very basic macros using "tools" and "record new macro". I need
to create one that will delete some columns and hide others. How can I do
this please?
Many thanks. I am working on excel 2003.




Mike

macro and deleting or hiding columns
 
Would you like to delete/hide any particular rows/columns? What is your
criteria for deleting/hiding?

The macro below will delete all blank rows in a selected range, is that any
good?

Sub Deleteblankrows()
Dim Rw As Range
If WorksheetFunction.CountA(Selection) = 0 Then
MsgBox "You didn't select a range", vbOKOnly
Exit Sub
End If
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
Selection.SpecialCells(xlCellTypeBlanks).Select
For Each Rw In Selection.Rows
If WorksheetFunction.CountA(Selection.EntireRow) = 0 Then
Selection.EntireRow.Delete
End If
Next Rw
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub

Mike

"Pascale" wrote:

Hello
I have done very basic macros using "tools" and "record new macro". I need
to create one that will delete some columns and hide others. How can I do
this please?
Many thanks. I am working on excel 2003.


Pascale

macro and deleting or hiding columns
 
Brilliant It works! However, I want to be able to use this macro with all my
spreadsheets, can you please tell me how to not have this macro attached to a
specific spreadsheet but be accessible to all spreadsheets opened or not?
thanks. Pascale

"Bob Phillips" wrote:


Columns("H:J").Delete
Columns("M:O").Hidden = True

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Pascale" wrote in message
...
Hello
I have done very basic macros using "tools" and "record new macro". I need
to create one that will delete some columns and hide others. How can I do
this please?
Many thanks. I am working on excel 2003.





Bob Phillips

macro and deleting or hiding columns
 
Do you mean sheets (within a workbook), or all workbooks in a folder?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Pascale" wrote in message
...
Brilliant It works! However, I want to be able to use this macro with all
my
spreadsheets, can you please tell me how to not have this macro attached
to a
specific spreadsheet but be accessible to all spreadsheets opened or not?
thanks. Pascale

"Bob Phillips" wrote:


Columns("H:J").Delete
Columns("M:O").Hidden = True

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Pascale" wrote in message
...
Hello
I have done very basic macros using "tools" and "record new macro". I
need
to create one that will delete some columns and hide others. How can I
do
this please?
Many thanks. I am working on excel 2003.








All times are GMT +1. The time now is 04:20 AM.

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