Solved

How do I get a macro to do nothing if column is blank?

Posted on 2008-10-02
2
174 Views
Last Modified: 2013-11-25
I have a macro to convert numbers with decimal places in column A to whole integers.  I want the macro, if ran, to do nothing if column A contains no data.  This macro is ran when a custom button in the Standard toolbar is clicked.
Public Sub RPM_to_MSProject()
 
   Dim Cell As Range
 
   For Each Cell In Intersect(ActiveSheet.[A3:A65536], ActiveSheet.UsedRange)
 
      Cell = Int(Len(Cell) / 2.1)
 
   Next Cell
 
End Sub

Open in new window

0
Comment
Question by:szadroga
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 50

Accepted Solution

by:
Dave Brett earned 250 total points
ID: 22624746
something like this

Cheers

Dave

Public Sub RPM_to_MSProject()
   Dim Cell As Range
   If Application.WorksheetFunction.CountA(Columns("A")) = 0 Then Exit Sub
   For Each Cell In Intersect(ActiveSheet.[A3:A65536], ActiveSheet.UsedRange)
      Cell = Int(Len(Cell) / 2.1)
   Next Cell
End Sub

Open in new window

0
 
LVL 59

Assisted Solution

by:Saurabh Singh Teotia
Saurabh Singh Teotia earned 250 total points
ID: 22624785
Or something like this....

Saurabh...
Public Sub RPM_to_MSProject()
 
   Dim Cell As Range
 
   For Each Cell In Intersect(ActiveSheet.[A3:A65536], ActiveSheet.UsedRange)
 if(cell.value<>"") then
      Cell = Int(Len(Cell) / 2.1)
 end if
   Next Cell
 
End Sub

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question