Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm very new to using VBA, other then recording and some basic stuff... I
have a lot to learn. My question is I have built a list of projects (Excel) in rows with different data for each project in the columns going on for maybe ten columns. When a project (row) is completed I have a percent complete in one of the columns. I'd like some help with some code that will look at a specific column (say H) for anything that is 100% and cut the entire row which it is in, then past into another sheet on the same workbook. The other sheet will be a running total of completed projects. Thank you in advance for any help, Gila |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Perhaps:
Sub lastr() n = Cells(Rows.Count, "H").End(xlUp).Row k = 1 For i = n To 1 Step -1 If Cells(i, "H").Value = 1 Then Cells(i, "H").EntireRow.Copy Sheets("Sheet2").Cells(k, 1) Cells(i, "H").EntireRow.Delete k = k + 1 End If Next End Sub -- Gary''s Student - gsnu200815 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you Gary''s Student,
This worked great, one thing though. After the code transferred the row from sheet1 to "sheet2" it placed it into row one. After testing it a second time I found it to over write the first transfer in sheet2. Can it be written to transfer the identified row(s) without overwriting rows with data in sheet2? "Gary''s Student" wrote: Perhaps: Sub lastr() n = Cells(Rows.Count, "H").End(xlUp).Row k = 1 For i = n To 1 Step -1 If Cells(i, "H").Value = 1 Then Cells(i, "H").EntireRow.Copy Sheets("Sheet2").Cells(k, 1) Cells(i, "H").EntireRow.Delete k = k + 1 End If Next End Sub -- Gary''s Student - gsnu200815 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub lastr()
n = Cells(Rows.Count, "H").End(xlUp).Row Sheets("Sheet2").Activate k = Application.WorksheetFunction.Max(1, Cells(Rows.Count, "H").End(xlUp).Row + 1) Sheets("Sheet1").Activate For i = n To 1 Step -1 If Cells(i, "H").Value = 1 Then Cells(i, "H").EntireRow.Copy Sheets("Sheet2").Cells(k, 1) Cells(i, "H").EntireRow.Delete k = k + 1 End If Next End Sub will not over-write any existing material on the second sheet. -- Gary''s Student - gsnu200815 "Gila" wrote: Thank you Gary''s Student, This worked great, one thing though. After the code transferred the row from sheet1 to "sheet2" it placed it into row one. After testing it a second time I found it to over write the first transfer in sheet2. Can it be written to transfer the identified row(s) without overwriting rows with data in sheet2? "Gary''s Student" wrote: Perhaps: Sub lastr() n = Cells(Rows.Count, "H").End(xlUp).Row k = 1 For i = n To 1 Step -1 If Cells(i, "H").Value = 1 Then Cells(i, "H").EntireRow.Copy Sheets("Sheet2").Cells(k, 1) Cells(i, "H").EntireRow.Delete k = k + 1 End If Next End Sub -- Gary''s Student - gsnu200815 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That is great!!!
Based off the code so far I modified it to look for anything with 60 in column "I" and delete that row. Id like it to look for anything 60 or higher (=60). I dont know how to do this expression in VBA though. Sub delete() n = Cells(Rows.Count, "I").End(xlUp).Row Sheets("Complete").Activate k = 1 For i = n To 1 Step -1 If Cells(i, "I").Value = 60 Then Cells(i, "I").EntireRow.delete k = k + 1 End If Next End Sub "Gary''s Student" wrote: Sub lastr() n = Cells(Rows.Count, "H").End(xlUp).Row Sheets("Sheet2").Activate k = Application.WorksheetFunction.Max(1, Cells(Rows.Count, "H").End(xlUp).Row + 1) Sheets("Sheet1").Activate For i = n To 1 Step -1 If Cells(i, "H").Value = 1 Then Cells(i, "H").EntireRow.Copy Sheets("Sheet2").Cells(k, 1) Cells(i, "H").EntireRow.Delete k = k + 1 End If Next End Sub will not over-write any existing material on the second sheet. -- Gary''s Student - gsnu200815 "Gila" wrote: Thank you Gary''s Student, This worked great, one thing though. After the code transferred the row from sheet1 to "sheet2" it placed it into row one. After testing it a second time I found it to over write the first transfer in sheet2. Can it be written to transfer the identified row(s) without overwriting rows with data in sheet2? "Gary''s Student" wrote: Perhaps: Sub lastr() n = Cells(Rows.Count, "H").End(xlUp).Row k = 1 For i = n To 1 Step -1 If Cells(i, "H").Value = 1 Then Cells(i, "H").EntireRow.Copy Sheets("Sheet2").Cells(k, 1) Cells(i, "H").EntireRow.Delete k = k + 1 End If Next End Sub -- Gary''s Student - gsnu200815 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just as it looks...........=60
Sub delete() Sheets("Complete").Activate n = Cells(Rows.Count, "I").End(xlUp).Row k = 1 For i = n To 1 Step -1 If Cells(i, "I").Value = 60 Then Cells(i, "I").EntireRow.delete k = k + 1 End If Next End Sub Gord Dibben MS Excel MVP On Mon, 24 Nov 2008 11:39:01 -0800, Gila wrote: That is great!!! Based off the code so far I modified it to look for anything with 60 in column "I" and delete that row. I’d like it to look for anything 60 or higher (=60). I don’t know how to do this expression in VBA though. Sub delete() n = Cells(Rows.Count, "I").End(xlUp).Row Sheets("Complete").Activate k = 1 For i = n To 1 Step -1 If Cells(i, "I").Value = 60 Then Cells(i, "I").EntireRow.delete k = k + 1 End If Next End Sub "Gary''s Student" wrote: Sub lastr() n = Cells(Rows.Count, "H").End(xlUp).Row Sheets("Sheet2").Activate k = Application.WorksheetFunction.Max(1, Cells(Rows.Count, "H").End(xlUp).Row + 1) Sheets("Sheet1").Activate For i = n To 1 Step -1 If Cells(i, "H").Value = 1 Then Cells(i, "H").EntireRow.Copy Sheets("Sheet2").Cells(k, 1) Cells(i, "H").EntireRow.Delete k = k + 1 End If Next End Sub will not over-write any existing material on the second sheet. -- Gary''s Student - gsnu200815 "Gila" wrote: Thank you Gary''s Student, This worked great, one thing though. After the code transferred the row from sheet1 to "sheet2" it placed it into row one. After testing it a second time I found it to over write the first transfer in sheet2. Can it be written to transfer the identified row(s) without overwriting rows with data in sheet2? "Gary''s Student" wrote: Perhaps: Sub lastr() n = Cells(Rows.Count, "H").End(xlUp).Row k = 1 For i = n To 1 Step -1 If Cells(i, "H").Value = 1 Then Cells(i, "H").EntireRow.Copy Sheets("Sheet2").Cells(k, 1) Cells(i, "H").EntireRow.Delete k = k + 1 End If Next End Sub -- Gary''s Student - gsnu200815 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Another thought...maybe I need it to (insert row(s)) not paste??? And would prefer to tell it what row to insert. Say row 3, as I have the first few rows locked under protect sheet. "Gary''s Student" wrote: Perhaps: Sub lastr() n = Cells(Rows.Count, "H").End(xlUp).Row k = 1 For i = n To 1 Step -1 If Cells(i, "H").Value = 1 Then Cells(i, "H").EntireRow.Copy Sheets("Sheet2").Cells(k, 1) Cells(i, "H").EntireRow.Delete k = k + 1 End If Next End Sub -- Gary''s Student - gsnu200815 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|