#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default VBA Help

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default VBA Help

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default VBA Help

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default VBA Help

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default VBA Help

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default VBA Help

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default VBA Help


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
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



All times are GMT +1. The time now is 01:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"