problem code

  • Thread starter Thread starter ksnapp
  • Start date Start date
K

ksnapp

ok here is how this sub is supposed to work:

I select a section in column H and then I run the sub.

When it finds a cell that is not blank in that selection of column H
it assigns that value to Dim A. Then it looks over in the A column an
moves up the A column until it finds a cell that is not blank.
When it finds the non blank cell in column A it then puts the value
in that row in column F.
the it moves on down the originaly selected column H

here is what really happens:

I make my selection and run the sub
it takes the value for all non blank cells in column H and copys the
into column M of the same row.

Here is my code, please help

Sub addthingspartb()

Dim A As Single
Dim X As Single

For Each cell In selection

If cell.Value <> "" Then
A = cell.Value
cell.Offset(0, -7).Select
If cell.Value = "" Then
cell.Offset(-1, 0).Select
Else
cell.Offset(0, 5).Value = A
End If



End If


Next cell

End Su
 
Try - this will not populate A1 if a1 blank



Sub addthingspartb()
Dim Cell As Range

For Each Cell In Selection

If Cell.Value <> "" Then

Range("a" & Range("a65536").End(xlUp).Row + 1).Value = Cell.Value
End If


Next Cell

End Sub
 

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