Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
looping?
Hello!
I have a production worksheet that information is entered into it on a daily basis. The information is gathered but used in two seperate worksheets. I have a macro set up for all of the general production totals in one of the seperate sheets. I want to take specific customer data from the entered info and place in the other worksheet without having to sort production cards or cut and paste. I came up with the following macro unfortunately, as it is it only gathers the information from the first row of the worksheet. I cannot figure out what I am doing incorrectly that it won't go to the next row? Please help my eyes are crossed and my brain is unwilling to take another day of the pain! Sub Button12_Click() Dim d1 As Variant Dim h1 As Variant Dim m1 As Variant Dim i As Integer, c As Integer, k As Integer c = 28 k = 0 i = 3 d1 = Sheets("daily production").Cells(i, c) d1 = Sheets("daily production").Cells(i, c).Value If d1 < 0 Then Sheets("daily production").Range("an1.ax1") = Sheets("daily production").Range("ab3.al3").Value If d1 = 0 Then For i = 3 To 25 Next i i = i + 1 d1 = Sheets("daily production").Cells(i + 1, c).Value h1 = Sheets("daily production").Range("ab3.al3").Value h1 = Sheets("daily production").Cells(c, 3).Value h1 = Sheets("daily production").Cells(c, i + 1).Value m1 = Sheets("daily production").Range("an1.ax1").Value m1 = Sheets("daily production").Cells(c + 10, k + 1).Value If m1 < "" Then k = k + 1 Do Until i = 25 Loop End If End If End If End Sub -- N/K |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
looping?
You code doesn't make a lot of sense. The code below is structured a lot
better then your original code but I couldn't figure out what you were doing so the code below probably doesn't work. Sub Button12_Click() Dim d1 As Variant Dim h1 As Variant Dim m1 As Variant Dim i As Integer, c As Integer, k As Integer c = 28 k = 1 For i = 3 To 25 d1 = Sheets("daily production").Cells(i, c) If d1 < 0 Then Sheets("daily production").Range("ab" & i & ":al" & i).Copy _ Destination:=Sheets("daily production").Range("an" & k & ":ax" & k) End If If d1 = 0 Then d1 = Sheets("daily production").Cells(i, c).Value h1 = Sheets("daily production").Cells(c, i + 1).Value m1 = Sheets("daily production").Cells(c + 10, k + 1).Value End If k = k + 1 Next i End Sub "nancy/karen" wrote: Hello! I have a production worksheet that information is entered into it on a daily basis. The information is gathered but used in two seperate worksheets. I have a macro set up for all of the general production totals in one of the seperate sheets. I want to take specific customer data from the entered info and place in the other worksheet without having to sort production cards or cut and paste. I came up with the following macro unfortunately, as it is it only gathers the information from the first row of the worksheet. I cannot figure out what I am doing incorrectly that it won't go to the next row? Please help my eyes are crossed and my brain is unwilling to take another day of the pain! Sub Button12_Click() Dim d1 As Variant Dim h1 As Variant Dim m1 As Variant Dim i As Integer, c As Integer, k As Integer c = 28 k = 0 i = 3 d1 = Sheets("daily production").Cells(i, c) d1 = Sheets("daily production").Cells(i, c).Value If d1 < 0 Then Sheets("daily production").Range("an1.ax1") = Sheets("daily production").Range("ab3.al3").Value If d1 = 0 Then For i = 3 To 25 Next i i = i + 1 d1 = Sheets("daily production").Cells(i + 1, c).Value h1 = Sheets("daily production").Range("ab3.al3").Value h1 = Sheets("daily production").Cells(c, 3).Value h1 = Sheets("daily production").Cells(c, i + 1).Value m1 = Sheets("daily production").Range("an1.ax1").Value m1 = Sheets("daily production").Cells(c + 10, k + 1).Value If m1 < "" Then k = k + 1 Do Until i = 25 Loop End If End If End If End Sub -- N/K |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
looping?
-- N/K "Joel" wrote: You code doesn't make a lot of sense. The code below is structured a lot better then your original code but I couldn't figure out what you were doing so the code below probably doesn't work. Sub Button12_Click() Dim d1 As Variant Dim h1 As Variant Dim m1 As Variant Dim i As Integer, c As Integer, k As Integer c = 28 k = 1 For i = 3 To 25 d1 = Sheets("daily production").Cells(i, c) If d1 < 0 Then Sheets("daily production").Range("ab" & i & ":al" & i).Copy _ Destination:=Sheets("daily production").Range("an" & k & ":ax" & k) End If If d1 = 0 Then d1 = Sheets("daily production").Cells(i, c).Value h1 = Sheets("daily production").Cells(c, i + 1).Value m1 = Sheets("daily production").Cells(c + 10, k + 1).Value End If k = k + 1 Next i End Sub "nancy/karen" wrote: Hello! I have a production worksheet that information is entered into it on a daily basis. The information is gathered but used in two seperate worksheets. I have a macro set up for all of the general production totals in one of the seperate sheets. I want to take specific customer data from the entered info and place in the other worksheet without having to sort production cards or cut and paste. I came up with the following macro unfortunately, as it is it only gathers the information from the first row of the worksheet. I cannot figure out what I am doing incorrectly that it won't go to the next row? Please help my eyes are crossed and my brain is unwilling to take another day of the pain! Sub Button12_Click() Dim d1 As Variant Dim h1 As Variant Dim m1 As Variant Dim i As Integer, c As Integer, k As Integer c = 28 k = 0 i = 3 d1 = Sheets("daily production").Cells(i, c) d1 = Sheets("daily production").Cells(i, c).Value If d1 < 0 Then Sheets("daily production").Range("an1.ax1") = Sheets("daily production").Range("ab3.al3").Value If d1 = 0 Then For i = 3 To 25 Next i i = i + 1 d1 = Sheets("daily production").Cells(i + 1, c).Value h1 = Sheets("daily production").Range("ab3.al3").Value h1 = Sheets("daily production").Cells(c, 3).Value h1 = Sheets("daily production").Cells(c, i + 1).Value m1 = Sheets("daily production").Range("an1.ax1").Value m1 = Sheets("daily production").Cells(c + 10, k + 1).Value If m1 < "" Then k = k + 1 Do Until i = 25 Loop End If End If End If End Sub -- N/K |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
looping?
the macro pulls info from the range "AB3:AL25"
the macro should look for only a specific customer's info that info is a numeric value greater than zero and located in column "AB" rows 3 through 25 If "AB" 3 equals zero then the info in row 3 in columns "AB" through "AL" should be ignored If "AB" 3 is greater than zero then the info in row 3 "AB" through "AL" should be copied to a new range destination starting at row 1 "AN" through "AX" and each subsequent blank row following. basically what the goal is to create a new range with the elimination of the rows that contain zero in "AB" 3 through 25 so that info can be transferred into the customer's worksheet without having to sort through the production cards by hand, pull out the specific customer's card, enter the info and to cut and paste into their worksheet -- N/K "nancy/karen" wrote: -- N/K "Joel" wrote: You code doesn't make a lot of sense. The code below is structured a lot better then your original code but I couldn't figure out what you were doing so the code below probably doesn't work. Sub Button12_Click() Dim d1 As Variant Dim h1 As Variant Dim m1 As Variant Dim i As Integer, c As Integer, k As Integer c = 28 k = 1 For i = 3 To 25 d1 = Sheets("daily production").Cells(i, c) If d1 < 0 Then Sheets("daily production").Range("ab" & i & ":al" & i).Copy _ Destination:=Sheets("daily production").Range("an" & k & ":ax" & k) End If If d1 = 0 Then d1 = Sheets("daily production").Cells(i, c).Value h1 = Sheets("daily production").Cells(c, i + 1).Value m1 = Sheets("daily production").Cells(c + 10, k + 1).Value End If k = k + 1 Next i End Sub "nancy/karen" wrote: Hello! I have a production worksheet that information is entered into it on a daily basis. The information is gathered but used in two seperate worksheets. I have a macro set up for all of the general production totals in one of the seperate sheets. I want to take specific customer data from the entered info and place in the other worksheet without having to sort production cards or cut and paste. I came up with the following macro unfortunately, as it is it only gathers the information from the first row of the worksheet. I cannot figure out what I am doing incorrectly that it won't go to the next row? Please help my eyes are crossed and my brain is unwilling to take another day of the pain! Sub Button12_Click() Dim d1 As Variant Dim h1 As Variant Dim m1 As Variant Dim i As Integer, c As Integer, k As Integer c = 28 k = 0 i = 3 d1 = Sheets("daily production").Cells(i, c) d1 = Sheets("daily production").Cells(i, c).Value If d1 < 0 Then Sheets("daily production").Range("an1.ax1") = Sheets("daily production").Range("ab3.al3").Value If d1 = 0 Then For i = 3 To 25 Next i i = i + 1 d1 = Sheets("daily production").Cells(i + 1, c).Value h1 = Sheets("daily production").Range("ab3.al3").Value h1 = Sheets("daily production").Cells(c, 3).Value h1 = Sheets("daily production").Cells(c, i + 1).Value m1 = Sheets("daily production").Range("an1.ax1").Value m1 = Sheets("daily production").Cells(c + 10, k + 1).Value If m1 < "" Then k = k + 1 Do Until i = 25 Loop End If End If End If End Sub -- N/K |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Looping | Excel Programming | |||
Why is this looping | Excel Programming | |||
Looping | Excel Programming | |||
Looping help please | Excel Programming | |||
looping every third row | Excel Programming |