Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copy Cells to new spreadsheet based on Cells(i, 4) value

Very new to VBA - my apologies for such a newbie question...

* Need to read each row in a spreasheet (number of rows in the
spreadsheet will always be changing)
* if there is a value in Cells(i, 4) I want to copy columns 4,5,7,10
to a new workbook. [one or more rows makes up one record - the value
in column 4 signifies a new record]
* This new spreadsheet will be turned into a CSV to feed another
program.



How would you approach this?
Any help is appreciated!!

-christian
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default Copy Cells to new spreadsheet based on Cells(i, 4) value

Some tips:
* Look up "last cell" in microsoft.public.excel.programming on Google
Groups. That will tell you how to find the last cell in a column, or sheet,
and hence the number of occupied rows.

* generally, copy works like this

Range-Object-to-copy-from.Copy Range-Object-to-copy-to

Workbook("Book1.xls").Worksheets("Sheet1").Columns (4).Copy Workbook(...
etc.

If needed, can do
Range-Object-to-copy-from.Copy
Range-Object-to-copy-to.PasteSpecial(<look up options)

* Can SaveAs csv type. Look up SaveAs.

* looping thru cells

Dim v as variant
For each v in <range.Cells
Debug.print v.Text
Next v

or

Dim n as Long '(not Integer; too small for all rows)
For n = 1 to <range.Cells.Count
Debug.Print <range.Cells(n).Text
Debug.Print <range.Cells(n,4).Text
Next n

Ranges are fully qualified if they include the workbook, worksheet, etc down
to the column, row, cell or cells you are interested in. If you don't
specifiy the workbook and worksheet, the default is the "active" one,
whatever that is at the time you run your code.

Bob

"christian" wrote in message
om...
Very new to VBA - my apologies for such a newbie question...

* Need to read each row in a spreasheet (number of rows in the
spreadsheet will always be changing)
* if there is a value in Cells(i, 4) I want to copy columns 4,5,7,10
to a new workbook. [one or more rows makes up one record - the value
in column 4 signifies a new record]
* This new spreadsheet will be turned into a CSV to feed another
program.



How would you approach this?
Any help is appreciated!!

-christian



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default Copy Cells to new spreadsheet based on Cells(i, 4) value

Should be "Workbooks("Book1.xls")..."

(plural; it is a Collection).

Look up Workbooks Collection, Add method, in Help too.


"Bob Kilmer" wrote in message
...
Some tips:
* Look up "last cell" in microsoft.public.excel.programming on Google
Groups. That will tell you how to find the last cell in a column, or

sheet,
and hence the number of occupied rows.

* generally, copy works like this

Range-Object-to-copy-from.Copy Range-Object-to-copy-to

Workbook("Book1.xls").Worksheets("Sheet1").Columns (4).Copy Workbook(...
etc.

If needed, can do
Range-Object-to-copy-from.Copy
Range-Object-to-copy-to.PasteSpecial(<look up options)

* Can SaveAs csv type. Look up SaveAs.

* looping thru cells

Dim v as variant
For each v in <range.Cells
Debug.print v.Text
Next v

or

Dim n as Long '(not Integer; too small for all rows)
For n = 1 to <range.Cells.Count
Debug.Print <range.Cells(n).Text
Debug.Print <range.Cells(n,4).Text
Next n

Ranges are fully qualified if they include the workbook, worksheet, etc

down
to the column, row, cell or cells you are interested in. If you don't
specifiy the workbook and worksheet, the default is the "active" one,
whatever that is at the time you run your code.

Bob

"christian" wrote in message
om...
Very new to VBA - my apologies for such a newbie question...

* Need to read each row in a spreasheet (number of rows in the
spreadsheet will always be changing)
* if there is a value in Cells(i, 4) I want to copy columns 4,5,7,10
to a new workbook. [one or more rows makes up one record - the value
in column 4 signifies a new record]
* This new spreadsheet will be turned into a CSV to feed another
program.



How would you approach this?
Any help is appreciated!!

-christian





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
How do I copy cells from one worksheet to another based on values Vickynh Excel Worksheet Functions 2 October 4th 08 05:18 AM
Copy certain cells in a row to another sheet, based on certain val AM Excel Worksheet Functions 2 August 25th 07 04:38 AM
Copy cells based on conditions to another workbook fLiPMoD£ Excel Discussion (Misc queries) 0 August 2nd 07 12:31 AM
Copy cells based on conditions to another workbook fLiPMoD£ Excel Worksheet Functions 0 August 2nd 07 12:31 AM
Scan and copy cells from one spreadsheet to another. Mark Excel Discussion (Misc queries) 1 April 6th 05 06:45 PM


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