Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Cut and Paste macro based on criteria then delete empty rows

Hi All,
First time poster and VBA bewbie. Any help would be great!!
I'm using ecxel 2000
Here's my problem:

I have a worksheet (Sheet1) from which I need to cut paste any row (in
the Range A3:AD300) where column "O" has a certain value in it into
Sheet2. I'd like the pasting to begin in the first blank row of
Sheet2. Then I'd like the blank rows of Sheet1 to be deleted. Is this
possible?


Many thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Cut and Paste macro based on criteria then delete empty rows

This should do what you want. Paste it into a general code module

Sub CutData()
Dim oWS1 As Worksheet
Dim oWS2 As Worksheet
Dim cRowLast As Long
Dim i As Long

Application.ScreenUpdating = False

Set oWS1 = Worksheets("Sheet1")
Set oWS2 = Worksheets("Sheet2")
cRowLast = oWS2.Cells(Rows.Count, "A").End(xlUp).Row
If cRowLast < 1 Or oWS2.Range("A1") < "" Then
cRowLast = cRowLast + 1
End If

For i = 300 To 3 Step -1
If oWS1.Cells(i, "O") = "test" Then
oWS1.Range("A" & i).EntireRow.Cut Destination:=oWS2.Range("A" &
cRowLast)
cRowLast = cRowLast + 1
oWS1.Range("A" & i).EntireRow.Delete
End If
Next i

Application.ScreenUpdating = True

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"samst" wrote in message
om...
Hi All,
First time poster and VBA bewbie. Any help would be great!!
I'm using ecxel 2000
Here's my problem:

I have a worksheet (Sheet1) from which I need to cut paste any row (in
the Range A3:AD300) where column "O" has a certain value in it into
Sheet2. I'd like the pasting to begin in the first blank row of
Sheet2. Then I'd like the blank rows of Sheet1 to be deleted. Is this
possible?


Many thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Cut and Paste macro based on criteria then delete empty rows

what about something like to move instead of cut/paste/delete
for each c in [o3:o300]
lastrow=sheets("sheet1").range("a65536").end(xlup) .row+1
if c="Joe" then c.entirerow cut sheets("sheet1").range("a2:a"&lastrow)
next

"samst" wrote in message
om...
Hi All,
First time poster and VBA bewbie. Any help would be great!!
I'm using ecxel 2000
Here's my problem:

I have a worksheet (Sheet1) from which I need to cut paste any row (in
the Range A3:AD300) where column "O" has a certain value in it into
Sheet2. I'd like the pasting to begin in the first blank row of
Sheet2. Then I'd like the blank rows of Sheet1 to be deleted. Is this
possible?


Many thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cut and Paste macro based on criteria then delete empty rows

Hi everyone
Thanks for your help but I think I'm doing something wrong

I copied your macro into Module 1 and put the word "test" in cell "o4"
and ran the macro but nothing happened. Any troubleshooting ideas?

thanks again


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Cut and Paste macro based on criteria then delete empty rows

Mail me your workbook direct and I will look at it.

Bob

"s ss" wrote in message
...
Hi everyone
Thanks for your help but I think I'm doing something wrong

I copied your macro into Module 1 and put the word "test" in cell "o4"
and ran the macro but nothing happened. Any troubleshooting ideas?

thanks again


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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
Delete Rows based on criteria in excel Novaglory Excel Discussion (Misc queries) 5 July 10th 07 08:29 PM
How can I delete rows programmatically based on certain criteria? nt_artagnian[_2_] New Users to Excel 2 March 8th 07 03:56 AM
Cut filtered rows, paste into next empty row of new sheet, and delete cut rows Scott Excel Worksheet Functions 0 December 13th 06 01:25 AM
Delete rows based on criteria Chris_t_2k5 Excel Discussion (Misc queries) 2 April 11th 06 01:52 PM
Delete rows based on certain criteria Coal Miner Excel Discussion (Misc queries) 2 March 3rd 06 05:56 PM


All times are GMT +1. The time now is 03:23 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"