Thread: move blank data
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Reza Reza is offline
external usenet poster
 
Posts: 88
Default move blank data

to all:

thanks for give me solution...
but like jacob said...yes i want it update automatically...so i do not run
every time again....

to Jacob:

What should i do with your macro code...should i use with your formula
above...can you tell me more detail...

thanks

"Jacob Skaria" wrote:

Rick

--the requirement is to have this to sheet2 automatically..I am not sure
whether Reza meant "as and when you change the values in the active sheet" or
just once..

--You can get the total rows; the below will do...

Reza

If you are looking for a one time copy of data from active sheet to sheet2
you can use the below straight away...If you are looking for the data in
sheet2 to update automatically I would suggest to go with the formula
solution itself; however you can try out the below macro to be called from
Worksheet change event....

Sub MyMacro()
Dim lngRow As Long, ws As Worksheet, lngNRow As Long
Set ws = Sheets("Sheet2"): ws.UsedRange.Clear
For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Range("C" & lngRow) < "" Then _
lngNRow = lngNRow + 1: Rows(lngRow).Copy ws.Rows(lngNRow)
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"BSc Chem Eng Rick" wrote:

Hi Reza,

Jacob has a good solution, if you'd prefer here is a macro I used to do this
task. It works well, if you need help give me a shout. Note, all you need to
change are the TotalRows and TotalCols variables which I have set to 5 as per
your example. Just copy this into a module and run.

Sub MySort()
Dim Orig As Worksheet, Destination As Worksheet
Dim RowOrig As Long, RowDest As Long
Dim TotalRows As String, TotalCols As Long
Dim Cell As Range
Set Orig = ActiveWorkbook.Worksheets("Sheet1")
Set Destination = ActiveWorkbook.Worksheets("Sheet2")
RowOrig = 1
RowDest = 1
TotalCols = 5
TotalRows = 5
Application.ScreenUpdating = False
Destination.Activate
Destination.Cells.Select
Selection.ClearContents
For Each Cell In Orig.Range("A1:A" & TotalRows)
If Cell.Value < "" Then
For Cols = 2 To TotalCols
If Orig.Cells(RowOrig, Cols) = "-" Then
Exit For
ElseIf Cols = TotalCols Then
Orig.Rows(RowOrig).Copy
Destination.Rows(RowDest).Select
ActiveSheet.Paste
RowDest = RowDest + 1
End If
Next Cols
End If
RowOrig = RowOrig + 1
Next Cell
Destination.Range("A1").Select
Application.ScreenUpdating = True
End Sub

"reza" wrote:

HI all....

i want to move data from sheet1 to another sheet, maybe it will need
macro...hope you can help me. Example...in sheet1 i have:
Line Col A Col B Col C Col D
AA 10 5 4 1
BB 5 - - -
FF 13 3 2 2
KK 10 - - -

now in sheet2 i want to create resume from sheet1 automatically....
but i want if col B is empty or no data...it can't move to sheet2...
so and in sheet2
Line Col A Col B Col C Col D
AA 10 5 4 1
FF 13 3 2 2


thanks in advance

reza