Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default cut rows to another sheet if a specific cell NOT BLANK

Hello:

I have been working on this all day and have the macro doing exactly
the opposite of what I want.

I have a workbook with 2 sheets. All data will start on sheet 1(In
Progress). I want to run a macro to move the rows that have any data
in col E to sheet 2 (Completed).

I have had problems making the selection of NOT EMPTY happen.

This is what I have - that works backwards!

' to copy completed items to completed sheet and delete from In
Progress

Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirstAddress As String
Set rngPaste = Sheets("Completed").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)
Set rngToSearch = ActiveSheet.Columns("E")

Set rngFound = rngToSearch.Find(What:="", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=True)

If rngFound Is Nothing Then
MsgBox "There are no items to move."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.EntireRow.Copy Destination:=rngPaste
rngFoundAll.EntireRow.Delete 'Optional to Delete
End If

Any help would be greatly appreciated!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default cut rows to another sheet if a specific cell NOT BLANK

Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirstAddress As String
Set rngPaste = Sheets("Completed").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)

sheets("Progress").activate '<= Add

Set rngToSearch = ActiveSheet.Columns("E")

Set rngFound = rngToSearch.Find(What:="", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=True)

If rngFound Is Nothing Then
MsgBox "There are no items to move."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.EntireRow.Copy Destination:=rngPaste
rngFoundAll.EntireRow.Delete 'Optional to Delete
End If


"JenIT" wrote:

Hello:

I have been working on this all day and have the macro doing exactly
the opposite of what I want.

I have a workbook with 2 sheets. All data will start on sheet 1(In
Progress). I want to run a macro to move the rows that have any data
in col E to sheet 2 (Completed).

I have had problems making the selection of NOT EMPTY happen.

This is what I have - that works backwards!

' to copy completed items to completed sheet and delete from In
Progress

Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirstAddress As String
Set rngPaste = Sheets("Completed").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)
Set rngToSearch = ActiveSheet.Columns("E")

Set rngFound = rngToSearch.Find(What:="", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=True)

If rngFound Is Nothing Then
MsgBox "There are no items to move."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.EntireRow.Copy Destination:=rngPaste
rngFoundAll.EntireRow.Delete 'Optional to Delete
End If

Any help would be greatly appreciated!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default cut rows to another sheet if a specific cell NOT BLANK

I can't understand why you are searching blank cell and copy it.

Set rngFound = rngToSearch.Find(What:="", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=True)

Is What:="" typo of What:="*" ? but not sure.

keizi

"JenIT" wrote in message
ups.com...
Hello:

I have been working on this all day and have the macro doing exactly
the opposite of what I want.

I have a workbook with 2 sheets. All data will start on sheet 1(In
Progress). I want to run a macro to move the rows that have any data
in col E to sheet 2 (Completed).

I have had problems making the selection of NOT EMPTY happen.

This is what I have - that works backwards!

' to copy completed items to completed sheet and delete from In
Progress

Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirstAddress As String
Set rngPaste = Sheets("Completed").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)
Set rngToSearch = ActiveSheet.Columns("E")

Set rngFound = rngToSearch.Find(What:="", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=True)

If rngFound Is Nothing Then
MsgBox "There are no items to move."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.EntireRow.Copy Destination:=rngPaste
rngFoundAll.EntireRow.Delete 'Optional to Delete
End If

Any help would be greatly appreciated!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default cut rows to another sheet if a specific cell NOT BLANK

Thanks to all for your help the "*" was what I needed.

As always this group is a super resouce for a VBA dabbler such as
myself. I appreciate the assistance.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy rows to new sheet based on specific cell value dlballard Excel Worksheet Functions 5 April 24th 23 11:44 AM
Inserting numerous blank lines between specific rows of data Deb Excel Discussion (Misc queries) 5 December 22nd 09 05:01 PM
Excel 2002: Any button to insert blank rows at specific interval? Mr. Low Excel Discussion (Misc queries) 5 March 29th 09 02:51 PM
To Delete the specific rows when blank is found on column A ddiicc Excel Programming 3 August 5th 05 05:32 AM
Checking specific cell, and identifing how many rows in the sheet Amy[_9_] Excel Programming 3 April 21st 05 03:57 PM


All times are GMT +1. The time now is 10:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"