Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Cam Cam is offline
external usenet poster
 
Posts: 165
Default VBA Programming help

Hello,

I have an Excel file with 2 worksheets. One containing Order Info called
"Orders" and another named "Analysis" which contact some fixed data and two
columns for automatic fill in from the "Orders" sheet.

I would like to create a code or macro when execute, transfer the Order# and
Prod Start columns from the "Orders" sheet to "Analysis" sheet taken the Qty
into account. so, if the order# has a quantity of 2, then it will fill in two
rows for one Order. The sample data is below. Thanks for any help.

Analysis sheet:
Line Plan Date Actual Date Order#
100 12/9/09
101 12/10/09
102 12/10/09
103 12/11/09
104 12/14/09
105 12/14/09
106 12/15/09
107 12/18/09
108 12/29/09

Orders Sheet:
Order# Prod Start Qty
167834 1/22/10 2
172916 2/1/10 2
169001 2/1/10 2
169003 2/2/10 2

RESULT of Analysis sheet:
Line Plan Date Actual Date Order#
100 12/9/09 1/22/10 167834
101 12/10/09 1/22/10 167834
102 12/10/09 2/1/10 172916
103 12/11/09 2/1/10 172916
104 12/14/09 2/1/10 169001
105 12/14/09 2/1/10 169001
106 12/15/09 2/2/10 169003
107 12/18/09 2/2/10 169003
108 12/29/09

  #2   Report Post  
Posted to microsoft.public.excel.programming
KC KC is offline
external usenet poster
 
Posts: 55
Default VBA Programming help

Programming exercise, not tested

Sub t()
Dim wsa As Worksheet
Dim wso As Worksheet
Dim rng As Range
Dim c As Range
Dim lrow As Long

Set wso = Worksheets("orders")
Set wsa = Worksheets("analysis")

lrow = wso.Cells(Rows.Count, 3).End(xlUp).Row
Set rng = Range(wso.Cells(2, 3), wso.Cells(lrow, 3))
With wsa
For Each c In rng
lrow = .Cells(Rows.Count, 3).End(xlUp).Row + 1
.Cells(lrow, 3).Resize(c, 1) = c.Offset(-1, 0)
.Cells(lrow, 4).Resize(c, 1) = c.Offset(-2, 0)
Next c
End With
End Sub

"Cam" wrote in message
...
Hello,

I have an Excel file with 2 worksheets. One containing Order Info called
"Orders" and another named "Analysis" which contact some fixed data and
two
columns for automatic fill in from the "Orders" sheet.

I would like to create a code or macro when execute, transfer the Order#
and
Prod Start columns from the "Orders" sheet to "Analysis" sheet taken the
Qty
into account. so, if the order# has a quantity of 2, then it will fill in
two
rows for one Order. The sample data is below. Thanks for any help.

Analysis sheet:
Line Plan Date Actual Date Order#
100 12/9/09
101 12/10/09
102 12/10/09
103 12/11/09
104 12/14/09
105 12/14/09
106 12/15/09
107 12/18/09
108 12/29/09

Orders Sheet:
Order# Prod Start Qty
167834 1/22/10 2
172916 2/1/10 2
169001 2/1/10 2
169003 2/2/10 2

RESULT of Analysis sheet:
Line Plan Date Actual Date Order#
100 12/9/09 1/22/10 167834
101 12/10/09 1/22/10 167834
102 12/10/09 2/1/10 172916
103 12/11/09 2/1/10 172916
104 12/14/09 2/1/10 169001
105 12/14/09 2/1/10 169001
106 12/15/09 2/2/10 169003
107 12/18/09 2/2/10 169003
108 12/29/09



  #3   Report Post  
Posted to microsoft.public.excel.programming
Cam Cam is offline
external usenet poster
 
Posts: 165
Default VBA Programming help

Hi KC,

I tried your code and got this error when I ran the macro.
"Run-time error '1004':
Application-defined or object-defined error"

And the Analysis sheet returns like this:
Line Plan Date Actual Date Order#
100 12/9/09 Qty
101 12/10/09 Qty
102 12/10/09
103 12/11/09
104 12/14/09
105 12/14/09
106 12/15/09
107 12/18/09
108 12/29/09

What is causing this? Thanks

"KC" wrote:

Programming exercise, not tested

Sub t()
Dim wsa As Worksheet
Dim wso As Worksheet
Dim rng As Range
Dim c As Range
Dim lrow As Long

Set wso = Worksheets("orders")
Set wsa = Worksheets("analysis")

lrow = wso.Cells(Rows.Count, 3).End(xlUp).Row
Set rng = Range(wso.Cells(2, 3), wso.Cells(lrow, 3))
With wsa
For Each c In rng
lrow = .Cells(Rows.Count, 3).End(xlUp).Row + 1
.Cells(lrow, 3).Resize(c, 1) = c.Offset(-1, 0)
.Cells(lrow, 4).Resize(c, 1) = c.Offset(-2, 0)
Next c
End With
End Sub

"Cam" wrote in message
...
Hello,

I have an Excel file with 2 worksheets. One containing Order Info called
"Orders" and another named "Analysis" which contact some fixed data and
two
columns for automatic fill in from the "Orders" sheet.

I would like to create a code or macro when execute, transfer the Order#
and
Prod Start columns from the "Orders" sheet to "Analysis" sheet taken the
Qty
into account. so, if the order# has a quantity of 2, then it will fill in
two
rows for one Order. The sample data is below. Thanks for any help.

Analysis sheet:
Line Plan Date Actual Date Order#
100 12/9/09
101 12/10/09
102 12/10/09
103 12/11/09
104 12/14/09
105 12/14/09
106 12/15/09
107 12/18/09
108 12/29/09

Orders Sheet:
Order# Prod Start Qty
167834 1/22/10 2
172916 2/1/10 2
169001 2/1/10 2
169003 2/2/10 2

RESULT of Analysis sheet:
Line Plan Date Actual Date Order#
100 12/9/09 1/22/10 167834
101 12/10/09 1/22/10 167834
102 12/10/09 2/1/10 172916
103 12/11/09 2/1/10 172916
104 12/14/09 2/1/10 169001
105 12/14/09 2/1/10 169001
106 12/15/09 2/2/10 169003
107 12/18/09 2/2/10 169003
108 12/29/09



.

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
Programming Min and Max Moises Excel Programming 2 January 11th 08 08:41 PM
programming [email protected] Excel Programming 0 August 24th 06 11:55 PM
programming [email protected] Excel Programming 0 August 24th 06 11:55 PM
How to add via programming ? Milind Excel Programming 3 September 10th 03 11:57 PM
Do I need programming for this? .NET Developer Excel Programming 2 August 18th 03 08:55 PM


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