Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Simple Macro - I think

Hi,

Pls help me with this. I have two workbook.

Workbook 1 - with columns A B C D

I need a macro that will do the following:

1) From workbook 1 - If the cell D1 = "x" , then I need to copy cells
A1& B1 to workbook 2.

2) I need the macro to go down the page in workbook 1 to identify the
criteria (I don't know what row it will end).

3) When pasting to workbook 2, i need the macro to identify a blank
row before pasting (there could be data there previuosly that i do not
want to delete).

Thankyou so much
KH

  #2   Report Post  
Posted to microsoft.public.excel.programming
KC KC is offline
external usenet poster
 
Posts: 107
Default Simple Macro - I think

Adjust workbook name and criteria to suit
try this

Sub t()
Dim rng As Range
Dim wb As Workbook
Dim ws As Worksheet
Dim targetrng As Range

Set awf = Application.WorksheetFunction
Set rng = Range(Cells(1, 4), Cells(1, 4).End(xlDown))
firstrow = awf.Match("x", rng, 0)
Rows("1:" & firstrow - 1).Delete
Range("A1").CurrentRegion.AutoFilter Field:=4, Criteria1:="x"
Cells(1, 1).CurrentRegion.Copy

Set wb = Workbooks.Open("workbook2.xls")
Set ws = wb.Sheets(1)
Set targetrng = ws.Range("a65536").End(xlUp)(2)
targetrng.PasteSpecial

End Sub

"missk" wrote:

Hi,

Pls help me with this. I have two workbook.

Workbook 1 - with columns A B C D

I need a macro that will do the following:

1) From workbook 1 - If the cell D1 = "x" , then I need to copy cells
A1& B1 to workbook 2.

2) I need the macro to go down the page in workbook 1 to identify the
criteria (I don't know what row it will end).

3) When pasting to workbook 2, i need the macro to identify a blank
row before pasting (there could be data there previuosly that i do not
want to delete).

Thankyou so much
KH


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Simple Macro - I think

Thank you so much. It worked.

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
simple macro widman Excel Discussion (Misc queries) 7 June 7th 08 08:57 PM
Simple (?) Macro NeedHelp Excel Discussion (Misc queries) 3 January 21st 07 10:39 PM
a simple macro? asalerno Excel Discussion (Misc queries) 2 April 28th 06 12:45 AM
Need help with simple macro garlnnd Excel Programming 4 October 5th 05 07:22 PM
Can't get simple macro to run Abi Excel Worksheet Functions 5 January 12th 05 07:37 PM


All times are GMT +1. The time now is 06:37 PM.

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

About Us

"It's about Microsoft Excel"