macros

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Macros

Macros

resolvedResolved · Low Priority · Version 2010

Christina has attended:
Excel VBA Intro Intermediate course

Macros

Is there a particular macro command I can use to count empty columns, rather than cells?

Is there a particular macro command to automatically save the workbook after the macro is done?

Is there a particular macro command to generate new workbooks rather than new tabs?

Edited on Wed 10 Oct 2012, 13:47

RE: Macros

Hi Christina

3 macro questions already!

Thanks very much they are very good and useful questions.
The first one I found from Google which originally counted blank rows.

The code for your other two questions were by recording.

Sub CountBlankColumns()
Dim Col As Long, ColCount As Long, Rng As Range

Set Rng = Selection
ColCount = 0

For Col = Rng.Columns.Count To 1 Step -1
If Application.WorksheetFunction.CountA(Rng.Columns(Col).EntireColumn) = 0 Then
ColCount = ColCount + 1

End If
Next Col

MsgBox ColCount & " columns found"

End Sub


Sub CreateandSave()


Workbooks.Add
ChDir "Z:\"
ActiveWorkbook.SaveAs Filename:="Z:\Christina.xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
End Sub

Instead of "Z:\" you can add your own file path for saving to

Hope that helps.

Regards
Doug
Best STL

Wed 17 Oct 2012: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Hiding and unhiding columns using the keyboard

CTRL + 0 hides your columns and CTRL + SHIFT + ) unhides them although you would need to highlight the column letters either side as per normal

View all Excel hints and tips


Server loaded in 0.07 secs.