Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looping through my worksheet and copying cells


Hello.

In my work I collect info from 10 individual workbooks from 10 material
controllers.
Each one of the material controllers summarize their suppliers part
number and which parts that goes out of stock in the next three days.

Each afternoon one person summarize all of the ten workbooks and filter
out which production line that will be out of parts in these three
days.

I am trying to do a script that copys the info written on each one of
the material controllers workbook into one new workbook. Each one of
the material controllers workbook get copied onto a new worksheet in
the new workbook.

This is how far I have gotten.

Here's my question:

On one worksheet I will summarize all ten worksheets.
I want to have a macro that loops through the first worksheet and copys
the info if the info on the worksheet is updated on the current day.
This information is written on each of the material controllers own
workbook and copied.

If the worksheet is updated I want excel to copy a cell range (A1:L1)
and so on to the worksheet where the summarize is being made.

Because of the fact that there might be written cells already in the
summarize worksheet it can't be over written. It must copy the value to
clear cells.

If someone can provide a script for me to deal with I would be very
glad and it would make my life a little easier.

Best regards

/Anders


--
a94andwi
------------------------------------------------------------------------
a94andwi's Profile: http://www.excelforum.com/member.php...o&userid=21077
View this thread: http://www.excelforum.com/showthread...hreadid=386117

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Looping through my worksheet and copying cells

I would think that you could refresh all the data--no matter if it's updated or
not.

If the summary didn't change, it'll still be copied into the new worksheet.

If that's ok, Ron de Bruin has tons of samples to combine worksheets from
different workbooks at:

http://www.rondebruin.nl/copy3.htm



a94andwi wrote:

Hello.

In my work I collect info from 10 individual workbooks from 10 material
controllers.
Each one of the material controllers summarize their suppliers part
number and which parts that goes out of stock in the next three days.

Each afternoon one person summarize all of the ten workbooks and filter
out which production line that will be out of parts in these three
days.

I am trying to do a script that copys the info written on each one of
the material controllers workbook into one new workbook. Each one of
the material controllers workbook get copied onto a new worksheet in
the new workbook.

This is how far I have gotten.

Here's my question:

On one worksheet I will summarize all ten worksheets.
I want to have a macro that loops through the first worksheet and copys
the info if the info on the worksheet is updated on the current day.
This information is written on each of the material controllers own
workbook and copied.

If the worksheet is updated I want excel to copy a cell range (A1:L1)
and so on to the worksheet where the summarize is being made.

Because of the fact that there might be written cells already in the
summarize worksheet it can't be over written. It must copy the value to
clear cells.

If someone can provide a script for me to deal with I would be very
glad and it would make my life a little easier.

Best regards

/Anders

--
a94andwi
------------------------------------------------------------------------
a94andwi's Profile: http://www.excelforum.com/member.php...o&userid=21077
View this thread: http://www.excelforum.com/showthread...hreadid=386117


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looping through my worksheet and copying cells


Hello again.

Now I have finally found out some way to loop through my files but
there are still some major functions I can't understand how to solve.

Here's the loop:

Do While FNames < ""

'SourceRcount = SourceRange.Rows.Count

Set myBook = Workbooks.Open(FNames)

Set SourceRange = myBook.Worksheets(1).Range("A4:L20")

SourceRcount = SourceRange.Rows.Count

'Set destrange = basebook.Worksheets(1).Cells(counter, "O")
Set destrange = basebook.Worksheets(1).Range("A4")


'Skriv in arbetsbokens namn i kolumn H
basebook.Worksheets(1).Cells(counter, "M").Value = myBook.Name
If myBook.Worksheets(1).Range("L1") = Date Then

'SourceRange.Copy destrange
' Instead of this line you can use the code below to copy only
the values

With SourceRange
'Set destrange = basebook.Worksheets(1).Cells(counter,
"O"). _
Resize(.Rows.Count,
..Columns.Count)
Set destrange = basebook.Worksheets(1).Range("A4"). _
Resize(.Rows.Count, .Columns.Count)
End With
destrange.Value = SourceRange.Value
End If

myBook.Close False

counter = counter + SourceRcount
FNames = Dir()

Loop

The lines written in red above are where I have difficulties.

On every new worksheet I want only the rows which has some values
copied onto the destination worksheet.
On the destination worksheet I want the first copied values to be
copied to Cell A4 and the next values on the cells A5, A6 and so on.
When the loop continues to the next file and copies the values I want
it to continue to copy the values the next empty cell in the
destination worksheet.

Anyone who can help me?

/anders


--
a94andwi
------------------------------------------------------------------------
a94andwi's Profile: http://www.excelforum.com/member.php...o&userid=21077
View this thread: http://www.excelforum.com/showthread...hreadid=386117

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Looping through my worksheet and copying cells

Since you're posting in plain text (thank you), none of the lines show up in
red.

Just add above the line you need an explanation for.

a94andwi wrote:

Hello again.

Now I have finally found out some way to loop through my files but
there are still some major functions I can't understand how to solve.

Here's the loop:

Do While FNames < ""

'SourceRcount = SourceRange.Rows.Count

Set myBook = Workbooks.Open(FNames)

Set SourceRange = myBook.Worksheets(1).Range("A4:L20")

SourceRcount = SourceRange.Rows.Count

'Set destrange = basebook.Worksheets(1).Cells(counter, "O")
Set destrange = basebook.Worksheets(1).Range("A4")

'Skriv in arbetsbokens namn i kolumn H
basebook.Worksheets(1).Cells(counter, "M").Value = myBook.Name
If myBook.Worksheets(1).Range("L1") = Date Then

'SourceRange.Copy destrange
' Instead of this line you can use the code below to copy only
the values

With SourceRange
'Set destrange = basebook.Worksheets(1).Cells(counter,
"O"). _
Resize(.Rows.Count,
Columns.Count)
Set destrange = basebook.Worksheets(1).Range("A4"). _
Resize(.Rows.Count, .Columns.Count)
End With
destrange.Value = SourceRange.Value
End If

myBook.Close False

counter = counter + SourceRcount
FNames = Dir()

Loop

The lines written in red above are where I have difficulties.

On every new worksheet I want only the rows which has some values
copied onto the destination worksheet.
On the destination worksheet I want the first copied values to be
copied to Cell A4 and the next values on the cells A5, A6 and so on.
When the loop continues to the next file and copies the values I want
it to continue to copy the values the next empty cell in the
destination worksheet.

Anyone who can help me?

/anders

--
a94andwi
------------------------------------------------------------------------
a94andwi's Profile: http://www.excelforum.com/member.php...o&userid=21077
View this thread: http://www.excelforum.com/showthread...hreadid=386117


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looping through my worksheet and copying cells


I'm sorry but when I see my previous inpput I see some lines colored in
red. Why can't you not see this?

/Anders
Here's the loop:

Code:
--------------------


Do While FNames < ""

'SourceRcount = SourceRange.Rows.Count

Set myBook = Workbooks.Open(FNames)

Set SourceRange = myBook.Worksheets(1).Range("A4:L20")

SourceRcount = SourceRange.Rows.Count

'Set destrange = basebook.Worksheets(1).Cells(counter, "O")
Set destrange = basebook.Worksheets(1).Range("A4")


'Skriv in arbetsbokens namn i kolumn H
basebook.Worksheets(1).Cells(counter, "M").Value = myBook.Name
If myBook.Worksheets(1).Range("L1") = Date Then

'SourceRange.Copy destrange
' Instead of this line you can use the code below to copy only the values

With SourceRange
'Set destrange = basebook.Worksheets(1).Cells(counter, "O"). _
Resize(.Rows.Count, .Columns.Count)
Set destrange = basebook.Worksheets(1).Range("A4"). _
Resize(.Rows.Count, .Columns.Count) End With
destrange.Value = SourceRange.Value
End If

myBook.Close False

counter = counter + SourceRcount
FNames = Dir()

Loop
--------------------

The lines written in red above are where I have difficulties.

On every new worksheet I want only the rows which has some values
copied onto the destination worksheet.
On the destination worksheet I want the first copied values to be
copied to Cell A4 and the next values on the cells A5, A6 and so on.
When the loop continues to the next file and copies the values I want
it to continue to copy the values the next empty cell in the
destination worksheet.

Anyone who can help me?

/anders


--
a94andwi
------------------------------------------------------------------------
a94andwi's Profile: http://www.excelforum.com/member.php...o&userid=21077
View this thread: http://www.excelforum.com/showthread...hreadid=386117



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Looping through my worksheet and copying cells

You're accessing the posts through ExcelForums. Many connect to MS Newsservers
directly. (I got through the msnewsservers and don't see your colors.)

Why not just copy all the data you want--and then when you're done, just wipe
out the blank rows in one step.

on error resume next
destrange.parent.columns(1) _
.cells.specialcells(xlcelltypeblanks).entirerow.de lete
on error goto 0

a94andwi wrote:

I'm sorry but when I see my previous inpput I see some lines colored in
red. Why can't you not see this?

/Anders
Here's the loop:

Code:
--------------------


Do While FNames < ""

'SourceRcount = SourceRange.Rows.Count

Set myBook = Workbooks.Open(FNames)

Set SourceRange = myBook.Worksheets(1).Range("A4:L20")

SourceRcount = SourceRange.Rows.Count

'Set destrange = basebook.Worksheets(1).Cells(counter, "O")
Set destrange = basebook.Worksheets(1).Range("A4")


'Skriv in arbetsbokens namn i kolumn H
basebook.Worksheets(1).Cells(counter, "M").Value = myBook.Name
If myBook.Worksheets(1).Range("L1") = Date Then

'SourceRange.Copy destrange
' Instead of this line you can use the code below to copy only the values

With SourceRange
'Set destrange = basebook.Worksheets(1).Cells(counter, "O"). _
Resize(.Rows.Count, .Columns.Count)
Set destrange = basebook.Worksheets(1).Range("A4"). _
Resize(.Rows.Count, .Columns.Count) End With
destrange.Value = SourceRange.Value
End If

myBook.Close False

counter = counter + SourceRcount
FNames = Dir()

Loop
--------------------

The lines written in red above are where I have difficulties.

On every new worksheet I want only the rows which has some values
copied onto the destination worksheet.
On the destination worksheet I want the first copied values to be
copied to Cell A4 and the next values on the cells A5, A6 and so on.
When the loop continues to the next file and copies the values I want
it to continue to copy the values the next empty cell in the
destination worksheet.

Anyone who can help me?

/anders

--
a94andwi
------------------------------------------------------------------------
a94andwi's Profile: http://www.excelforum.com/member.php...o&userid=21077
View this thread: http://www.excelforum.com/showthread...hreadid=386117


--

Dave Peterson
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
Copying worksheet cells into another worksheet using autofill SunnySD Excel Discussion (Misc queries) 3 September 10th 08 10:32 PM
Copying a worksheet witrh protected cells to a new worksheet John Excel Worksheet Functions 2 February 1st 06 02:19 PM
looping and copying from onesheet to othersheet Lolly[_2_] Excel Programming 0 August 22nd 04 03:07 PM
Looping down list and each time copying to another worksheet mattri Excel Programming 2 February 16th 04 06:26 PM
Looping down list and each time copying to another worksheet Matthew Richards Excel Programming 0 February 16th 04 04:58 PM


All times are GMT +1. The time now is 07:20 AM.

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"