Cell Transfer

L

louis2112

What code do I use to carry over a range of columm of cells over t
another sheet, only if they have a value in them.


i.e. columm B has 1130, 1000, , 330,

and I want to be able to carry those 3 values, ignore the value wit
nothing, and line them up on a seperate sheet such as

1130,1000,330

Thanks!

Loui
 
F

Frank Kabel

Hi
one way:

Sub transfer()
Dim lastrow
Dim source_wks As Worksheet
Dim target_wks As Worksheet
Dim source_row As Long
Dim target_row As Long

Set source_wks = Worksheets("Sheet1")
Set target_wks = Worksheets("sheet2")
target_row = 1
lastrow = source_wks.Cells(Rows.Count, "B").End(xlUp).Row
Application.ScreenUpdating = False
With source_wks
For source_row = 1 To lastrow
If .Cells(source_row, "B").Value <> "" Then
target_wks.Cells(target_row, "A").Value = _
..Cells(source_row, "B").Value
target_row = target_row + 1
End If
Next
End With
Application.ScreenUpdating = True
End Sub
 
Top