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

macros

ResolvedVersion 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:

Paste functions box quickly

If you want to do a formula using the paste functions box press SHIFT + F3.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.