![]() |
How to create a macro to control data flow
I need to create a macro to transfer info from one worksheet to another based
on the input of a certain cell. Example of what I'm trying to do: Workbook 1 Sheet 1: A B C D 1 Name Type ID User If Sheet 1 B3 = Blue, send data in row 3 to sheet 2, next availiable row, and also to Sheet 4 next availiable row. If Sheet 1 B3 = Green, send data in row 3 to sheet 3, next availiable row and also Sheet 4 next availiable row. And I am also creating sheet 5 to do some scheduling and tracking which I can adjust the process as needed. I'd appreciate any help. Thanks, |
How to create a macro to control data flow
Sub copy2sheets()
Dim i As Long, j as long, s2row As Long, s3row As Long, s4row As Long i = 2 s2row = 2 s3row = 2 s4row = 3 While Sheets("Sheet1").Cells(i, 1) < "" If Sheets("Sheet1").Cells(i, 2) = "Blue" Then For j = 1 To 4 Sheets("Sheet2").Cells(s2row, j).Value = Sheets("Sheet1").Cells(i, j).Value Sheets("Sheet4").Cells(s4row, j).Value = Sheets("Sheet1").Cells(i, j).Value Next j s2row = s2row + 1 s4row = s4row + 1 ElseIf Sheets("Sheet1").Cells(i, 2) = "Green" Then For j = 1 To 4 Sheets("Sheet3").Cells(s3row, j).Value = Sheets("Sheet1").Cells(i, j).Value Sheets("Sheet4").Cells(s4row, j).Value = Sheets("Sheet1").Cells(i, j).Value Next j s3row = s3row + 1 s4row = s4row + 1 End If i = i + 1 Wend End Sub HTH Kostis Vezerides On Mar 28, 4:04*pm, JW_4222 wrote: I need to create a macro to transfer info from one worksheet to another based on the input of a certain cell. Example of what I'm trying to do: Workbook 1 Sheet 1: * * * *A * * * * * B * * * * * C * * * * *D 1 * Name * * Type * * ID * * * * User If * Sheet 1 B3 = Blue, send data in row 3 to sheet 2, next availiable row, and also to Sheet 4 next availiable row. If *Sheet 1 B3 = Green, send data in row 3 to sheet 3, next availiable row and also Sheet 4 next availiable row. And I am also creating sheet 5 to do some scheduling and tracking which I can adjust the process as needed. I'd appreciate any help. Thanks, |
All times are GMT +1. The time now is 07:02 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com