Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Copy Cells Based on Criteria in VBA

I have a worksheet I'm using for tracking projects set up in a List (XL2003)
as follows:

A B C
1 Project Comments Status
2 Kaizen1 in process Active
3 CEDAC1 Active
4 CEDAC2 successful Complete

I am currently running the following code weekly to move the comments (or
lack of comments) to consecutive columns to the right of this beginning in
column F so that people can view comment history about a project but clear
the comment section for next week's input.

Sub MoveComments()

Range("B2:B4").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = " "
With Selection.Characters(Start:=1, Length:=1).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.Copy
Range("B2:B4").Copy
Range("BZ2").End(xlToLeft).Offset(, 1).PasteSpecial
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
With Range("BZ1").End(xlToLeft).Offset(, 1)
.Value = Date
.NumberFormat = "mm/dd/yy"
End With
Range("B2:B4").ClearContents
Range("B2").Select
Application.CutCopyMode = False
End Sub

What I would like it to do is to move and clear the comments only from those
rows where the "Status" is listed as "Active" and leave the comments in
column B for those that are listed as "Complete".

Any help you can provide (as well as suggestions to clean up my existing
code) is greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Copy Cells Based on Criteria in VBA

Sub MoveComments()

LastRow = Range("A" & Rows.Count).end(xlup).Row

with Range("B2:B4")
.SpecialCells(xlCellTypeBlanks).Select
.FormulaR1C1 = " "

With .Characters(Start:=1, Length:=1).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
end with

LastCol = Cells(1,Columns.Count).End(xlToLeft).Column
For rowCount = 2 to LastRow
if Range("C" & RowCount) = "Active" then

Range("B" & RowCount).Copy
cells(RowCount, LastCol + 1).PasteSpecial _
Paste:=xlPasteValues
with cells(1, LastCol + 1)
.Value = Date
.NumberFormat = "mm/dd/yy"
End With
Range("B" & RowCount).ClearContents
end if
next rowcount
Range("B2").Select
Application.CutCopyMode = False
End Sub


"bugsyb6" wrote:

I have a worksheet I'm using for tracking projects set up in a List (XL2003)
as follows:

A B C
1 Project Comments Status
2 Kaizen1 in process Active
3 CEDAC1 Active
4 CEDAC2 successful Complete

I am currently running the following code weekly to move the comments (or
lack of comments) to consecutive columns to the right of this beginning in
column F so that people can view comment history about a project but clear
the comment section for next week's input.

Sub MoveComments()

Range("B2:B4").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = " "
With Selection.Characters(Start:=1, Length:=1).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.Copy
Range("B2:B4").Copy
Range("BZ2").End(xlToLeft).Offset(, 1).PasteSpecial
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
With Range("BZ1").End(xlToLeft).Offset(, 1)
.Value = Date
.NumberFormat = "mm/dd/yy"
End With
Range("B2:B4").ClearContents
Range("B2").Select
Application.CutCopyMode = False
End Sub

What I would like it to do is to move and clear the comments only from those
rows where the "Status" is listed as "Active" and leave the comments in
column B for those that are listed as "Complete".

Any help you can provide (as well as suggestions to clean up my existing
code) is greatly appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Copy Cells Based on Criteria in VBA

Joel -
Thanks for the quick reply, but there's just one issue. The data in B2:B4 is
cleared right after the .FormulaR1C1 = " " line of code runs so there is
nothing that is pasted. Any ideas what could be wrong?

bugsyb6


"Joel" wrote:

Sub MoveComments()

LastRow = Range("A" & Rows.Count).end(xlup).Row

with Range("B2:B4")
.SpecialCells(xlCellTypeBlanks).Select
.FormulaR1C1 = " "

With .Characters(Start:=1, Length:=1).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
end with

LastCol = Cells(1,Columns.Count).End(xlToLeft).Column
For rowCount = 2 to LastRow
if Range("C" & RowCount) = "Active" then

Range("B" & RowCount).Copy
cells(RowCount, LastCol + 1).PasteSpecial _
Paste:=xlPasteValues
with cells(1, LastCol + 1)
.Value = Date
.NumberFormat = "mm/dd/yy"
End With
Range("B" & RowCount).ClearContents
end if
next rowcount
Range("B2").Select
Application.CutCopyMode = False
End Sub


"bugsyb6" wrote:

I have a worksheet I'm using for tracking projects set up in a List (XL2003)
as follows:

A B C
1 Project Comments Status
2 Kaizen1 in process Active
3 CEDAC1 Active
4 CEDAC2 successful Complete

I am currently running the following code weekly to move the comments (or
lack of comments) to consecutive columns to the right of this beginning in
column F so that people can view comment history about a project but clear
the comment section for next week's input.

Sub MoveComments()

Range("B2:B4").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = " "
With Selection.Characters(Start:=1, Length:=1).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.Copy
Range("B2:B4").Copy
Range("BZ2").End(xlToLeft).Offset(, 1).PasteSpecial
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
With Range("BZ1").End(xlToLeft).Offset(, 1)
.Value = Date
.NumberFormat = "mm/dd/yy"
End With
Range("B2:B4").ClearContents
Range("B2").Select
Application.CutCopyMode = False
End Sub

What I would like it to do is to move and clear the comments only from those
rows where the "Status" is listed as "Active" and leave the comments in
column B for those that are listed as "Complete".

Any help you can provide (as well as suggestions to clean up my existing
code) is greatly appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Copy Cells Based on Criteria in VBA

try this instead. I don't think you want to put a space in the blank cells.

Sub MoveComments()

LastRow = Range("A" & Rows.Count).end(xlup).Row

with Range("B2:B4").SpecialCells(xlCellTypeBlanks)

With .Characters(Start:=1, Length:=1).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
end with

LastCol = Cells(1,Columns.Count).End(xlToLeft).Column
For rowCount = 2 to LastRow
if Range("C" & RowCount) = "Active" then

Range("B" & RowCount).Copy
cells(RowCount, LastCol + 1).PasteSpecial _
Paste:=xlPasteValues
with cells(1, LastCol + 1)
.Value = Date
.NumberFormat = "mm/dd/yy"
End With
Range("B" & RowCount).ClearContents
end if
next rowcount
Range("B2").Select
Application.CutCopyMode = False
End Sub


"bugsyb6" wrote:

Joel -
Thanks for the quick reply, but there's just one issue. The data in B2:B4 is
cleared right after the .FormulaR1C1 = " " line of code runs so there is
nothing that is pasted. Any ideas what could be wrong?

bugsyb6


"Joel" wrote:

Sub MoveComments()

LastRow = Range("A" & Rows.Count).end(xlup).Row

with Range("B2:B4")
.SpecialCells(xlCellTypeBlanks).Select
.FormulaR1C1 = " "

With .Characters(Start:=1, Length:=1).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
end with

LastCol = Cells(1,Columns.Count).End(xlToLeft).Column
For rowCount = 2 to LastRow
if Range("C" & RowCount) = "Active" then

Range("B" & RowCount).Copy
cells(RowCount, LastCol + 1).PasteSpecial _
Paste:=xlPasteValues
with cells(1, LastCol + 1)
.Value = Date
.NumberFormat = "mm/dd/yy"
End With
Range("B" & RowCount).ClearContents
end if
next rowcount
Range("B2").Select
Application.CutCopyMode = False
End Sub


"bugsyb6" wrote:

I have a worksheet I'm using for tracking projects set up in a List (XL2003)
as follows:

A B C
1 Project Comments Status
2 Kaizen1 in process Active
3 CEDAC1 Active
4 CEDAC2 successful Complete

I am currently running the following code weekly to move the comments (or
lack of comments) to consecutive columns to the right of this beginning in
column F so that people can view comment history about a project but clear
the comment section for next week's input.

Sub MoveComments()

Range("B2:B4").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = " "
With Selection.Characters(Start:=1, Length:=1).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.Copy
Range("B2:B4").Copy
Range("BZ2").End(xlToLeft).Offset(, 1).PasteSpecial
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
With Range("BZ1").End(xlToLeft).Offset(, 1)
.Value = Date
.NumberFormat = "mm/dd/yy"
End With
Range("B2:B4").ClearContents
Range("B2").Select
Application.CutCopyMode = False
End Sub

What I would like it to do is to move and clear the comments only from those
rows where the "Status" is listed as "Active" and leave the comments in
column B for those that are listed as "Complete".

Any help you can provide (as well as suggestions to clean up my existing
code) is greatly appreciated.

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
Copy cells from one sheet to another based on criteria Nathalie Excel Programming 1 December 23rd 08 01:48 AM
Copy Row to worksheet based on criteria JoePineapples Excel Discussion (Misc queries) 1 March 7th 07 09:05 AM
Copy/Paste based on Criteria Dan R. Excel Programming 2 February 5th 07 08:25 PM
Filter/copy based on criteria gavmer[_86_] Excel Programming 0 October 5th 04 12:32 AM
Filter/copy based on criteria gavmer[_84_] Excel Programming 0 October 1st 04 03:14 AM


All times are GMT +1. The time now is 11:18 AM.

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"