Solved

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

Posted on 2008-10-02
2
175 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
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…

729 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