macro and deleting or hiding columns

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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)
 
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
 
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
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top