[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2008-10-02
2
Medium Priority
?
180 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 1000 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 1000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

649 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