Macro Coding

  • Thread starter Thread starter Duster142
  • Start date Start date
D

Duster142

Gee,

I find myself here seaking help again and just when I thought I wa
getting a hand on how this MACRO stuff and the coding worked.

I have found an other coding challenge that I can't firgure out on m
own. Can one of you smart MACRO Coding experts please help. I hav
played with this for over a week and just can't firgure it out on m
own.

I am trying to develop is a MACRO that will seach an entire colum an
everytime it finds a number greater than "0" it will move that numbe
to the left one colum.

Here is a sample of the type Data elemets from a spreadsheet that
currently working:

Z00056 1 13 0 0.7 0
Z00384 4 4 0 0 0
Z32566 3 261 0 15 0
Z39441 1 67 0 2 0
Z46135 1 340 0 33 0
Z53098 1 46 0 3.12 0
Z72045 1 55 0 4.5 0
Z72475 1 5 0 0.11 0
C18234 2 0 6240 0 150
D12087 0 0 0 0 0
F40375 0 0 0 0 0
T60081 0 0 0 0 0
T61494 0 0 0 0 0
T61908 1 0 10000 0 537
W98825 0 0 0 0 0
X40009 0 0 0 0 0
Z36683 1 0 10000 0 0

Thanks in advance for any help provided and have a great Turkey Day,
Ro
 
Try this

Sub DelZeroes()
Dim rng As Range
Dim Cel As Range
Dim DelRng As Range
Set DelRng = Nothing
Set rng = Selection

For Each Cel In rng
If Cel.Value = 0 Then
If DelRng Is Nothing Then
Set DelRng = Cel
Else
Set DelRng = Union(DelRng, Cel)
End If
End If
Next
If Not DelRng Is Nothing Then
DelRng.Delete Shift:=xlToLeft
End If
End Sub

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

------------------------------­------------------------------­----------------
It's easier to beg forgiveness than ask permission :-)
------------------------------­------------------------------­----------------
 
Thank you ken,

This works perfect and you my friend are a genius. I worked on this for
better than a week and I had a young intern work on it for the better
part of another week and neither of us could make it work. That goes to
show you the difference between an experienced person and novelist such
as myself. You should know that this bit of code that you did will save
several people in my office a ton of cut and paste action.

Again my many thinks to you for your assistance. :)

Ron
 
You're very welcome, and I appreciate the feedback. :-)

Regards
Ken...................
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top