Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default Paste values for entire row based on cell contents

Hi all

Hoping someone can help out. I want to paste the values in the entire row
based on the contents of one cell in that row.

Column Q is "Approved Status" with formula that is either Current or
Expired. When the formula changes to expired, the user activates a macro to
send an email with the expired cases. Expired then changes to Emailed. I
would like all the cells in that row to then be copied and pasted with their
values rather than the formula that exist in the other cells. This is the
macro I have so far - thanks to Ron DeBruin:

Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007

ActiveSheet.Unprotect
Selection.AutoFilter Field:=16, Criteria1:="expired"
Rows("2:2").Select
Range("B2").Activate
Selection.EntireRow.Hidden = True


Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
Set rng =
Sheets("Approvals").Range("b3:q20").SpecialCells(x lCellTypeVisible)

On Error GoTo 0


If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If

With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "CRCs Requiring New Approvals - Please Action"
.HTMLBody = RangetoHTML(rng)
.Display
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing

Selection.AutoFilter Field:=16
Cells.Select
Range("B3").Activate
Selection.EntireRow.Hidden = False
Rows("1:1").Select
Range("B1").Activate
Selection.EntireRow.Hidden = True

ActiveSheet.Unprotect
Range("B3:U13").Select
Selection.sort Key1:=Range("Q4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal



n = Cells(Rows.Count, "q").End(xlUp).Row
For i = 1 To n
With Cells(i, "q")
If .Value = "Expired" Then .Value = "Emailed"
End With
Next


ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFiltering:=True
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default Paste values for entire row based on cell contents

If you want to paste the row on itself then use the following;

Rows(i & ":" & i).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

It will paste row i on itself as values...

"Janelle S" wrote:

Hi all

Hoping someone can help out. I want to paste the values in the entire row
based on the contents of one cell in that row.

Column Q is "Approved Status" with formula that is either Current or
Expired. When the formula changes to expired, the user activates a macro to
send an email with the expired cases. Expired then changes to Emailed. I
would like all the cells in that row to then be copied and pasted with their
values rather than the formula that exist in the other cells. This is the
macro I have so far - thanks to Ron DeBruin:

Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007

ActiveSheet.Unprotect
Selection.AutoFilter Field:=16, Criteria1:="expired"
Rows("2:2").Select
Range("B2").Activate
Selection.EntireRow.Hidden = True


Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
Set rng =
Sheets("Approvals").Range("b3:q20").SpecialCells(x lCellTypeVisible)

On Error GoTo 0


If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If

With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "CRCs Requiring New Approvals - Please Action"
.HTMLBody = RangetoHTML(rng)
.Display
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing

Selection.AutoFilter Field:=16
Cells.Select
Range("B3").Activate
Selection.EntireRow.Hidden = False
Rows("1:1").Select
Range("B1").Activate
Selection.EntireRow.Hidden = True

ActiveSheet.Unprotect
Range("B3:U13").Select
Selection.sort Key1:=Range("Q4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal



n = Cells(Rows.Count, "q").End(xlUp).Row
For i = 1 To n
With Cells(i, "q")
If .Value = "Expired" Then .Value = "Emailed"
End With
Next


ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFiltering:=True
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default Paste values for entire row based on cell contents

Thanks Sheeloo

How do I 'tell it' to only do this to the rows with "Emailed" in column Q.

"Sheeloo" wrote:

If you want to paste the row on itself then use the following;

Rows(i & ":" & i).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

It will paste row i on itself as values...

"Janelle S" wrote:

Hi all

Hoping someone can help out. I want to paste the values in the entire row
based on the contents of one cell in that row.

Column Q is "Approved Status" with formula that is either Current or
Expired. When the formula changes to expired, the user activates a macro to
send an email with the expired cases. Expired then changes to Emailed. I
would like all the cells in that row to then be copied and pasted with their
values rather than the formula that exist in the other cells. This is the
macro I have so far - thanks to Ron DeBruin:

Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007

ActiveSheet.Unprotect
Selection.AutoFilter Field:=16, Criteria1:="expired"
Rows("2:2").Select
Range("B2").Activate
Selection.EntireRow.Hidden = True


Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
Set rng =
Sheets("Approvals").Range("b3:q20").SpecialCells(x lCellTypeVisible)

On Error GoTo 0


If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If

With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "CRCs Requiring New Approvals - Please Action"
.HTMLBody = RangetoHTML(rng)
.Display
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing

Selection.AutoFilter Field:=16
Cells.Select
Range("B3").Activate
Selection.EntireRow.Hidden = False
Rows("1:1").Select
Range("B1").Activate
Selection.EntireRow.Hidden = True

ActiveSheet.Unprotect
Range("B3:U13").Select
Selection.sort Key1:=Range("Q4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal



n = Cells(Rows.Count, "q").End(xlUp).Row
For i = 1 To n
With Cells(i, "q")
If .Value = "Expired" Then .Value = "Emailed"
End With
Next


ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFiltering:=True
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default Paste values for entire row based on cell contents


Put it inside the IF in your i loop which is already checking for the
condition.
"Janelle S" wrote:

Thanks Sheeloo

How do I 'tell it' to only do this to the rows with "Emailed" in column Q.

"Sheeloo" wrote:

If you want to paste the row on itself then use the following;

Rows(i & ":" & i).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

It will paste row i on itself as values...

"Janelle S" wrote:

Hi all

Hoping someone can help out. I want to paste the values in the entire row
based on the contents of one cell in that row.

Column Q is "Approved Status" with formula that is either Current or
Expired. When the formula changes to expired, the user activates a macro to
send an email with the expired cases. Expired then changes to Emailed. I
would like all the cells in that row to then be copied and pasted with their
values rather than the formula that exist in the other cells. This is the
macro I have so far - thanks to Ron DeBruin:

Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007

ActiveSheet.Unprotect
Selection.AutoFilter Field:=16, Criteria1:="expired"
Rows("2:2").Select
Range("B2").Activate
Selection.EntireRow.Hidden = True


Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
Set rng =
Sheets("Approvals").Range("b3:q20").SpecialCells(x lCellTypeVisible)

On Error GoTo 0


If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If

With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "CRCs Requiring New Approvals - Please Action"
.HTMLBody = RangetoHTML(rng)
.Display
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing

Selection.AutoFilter Field:=16
Cells.Select
Range("B3").Activate
Selection.EntireRow.Hidden = False
Rows("1:1").Select
Range("B1").Activate
Selection.EntireRow.Hidden = True

ActiveSheet.Unprotect
Range("B3:U13").Select
Selection.sort Key1:=Range("Q4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal



n = Cells(Rows.Count, "q").End(xlUp).Row
For i = 1 To n
With Cells(i, "q")
If .Value = "Expired" Then .Value = "Emailed"
End With
Next


ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFiltering:=True
End Sub



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default Paste values for entire row based on cell contents

Hi Sheeloo

I am obviously doing something majorly wrong. I have put it in - but the
result is all formula in the worksheet are replaced. I really appreciate your
help on this.

n = Cells(Rows.Count, "q").End(xlUp).Row
For i = 1 To n
With Cells(i, "q")
If .Value = "Expired" Then .Value = "Emailed"
Rows(i & ":" & i).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
skipBlanks:=False, Transpose:=False

End With
Next

"Sheeloo" wrote:


Put it inside the IF in your i loop which is already checking for the
condition.
"Janelle S" wrote:

Thanks Sheeloo

How do I 'tell it' to only do this to the rows with "Emailed" in column Q.

"Sheeloo" wrote:

If you want to paste the row on itself then use the following;

Rows(i & ":" & i).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

It will paste row i on itself as values...

"Janelle S" wrote:

Hi all

Hoping someone can help out. I want to paste the values in the entire row
based on the contents of one cell in that row.

Column Q is "Approved Status" with formula that is either Current or
Expired. When the formula changes to expired, the user activates a macro to
send an email with the expired cases. Expired then changes to Emailed. I
would like all the cells in that row to then be copied and pasted with their
values rather than the formula that exist in the other cells. This is the
macro I have so far - thanks to Ron DeBruin:

Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007

ActiveSheet.Unprotect
Selection.AutoFilter Field:=16, Criteria1:="expired"
Rows("2:2").Select
Range("B2").Activate
Selection.EntireRow.Hidden = True


Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
Set rng =
Sheets("Approvals").Range("b3:q20").SpecialCells(x lCellTypeVisible)

On Error GoTo 0


If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If

With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "CRCs Requiring New Approvals - Please Action"
.HTMLBody = RangetoHTML(rng)
.Display
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing

Selection.AutoFilter Field:=16
Cells.Select
Range("B3").Activate
Selection.EntireRow.Hidden = False
Rows("1:1").Select
Range("B1").Activate
Selection.EntireRow.Hidden = True

ActiveSheet.Unprotect
Range("B3:U13").Select
Selection.sort Key1:=Range("Q4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal



n = Cells(Rows.Count, "q").End(xlUp).Row
For i = 1 To n
With Cells(i, "q")
If .Value = "Expired" Then .Value = "Emailed"
End With
Next


ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFiltering:=True
End Sub





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default Paste values for entire row based on cell contents

Try this
n = Cells(Rows.Count, "q").End(xlUp).Row
For i = 1 To n
With Cells(i, "q")
If .Value = "Expired" Then
..Value = "Emailed"
Rows(i & ":" & i).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
skipBlanks:=False, Transpose:=False
End IF

End With

The way you have written it, your IF ends on the line
If .Value = "Expired" Then .Value = "Emailed"

Notice that I have moved .Value = "Emailed" to the next line and added END
IF at the end
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default Paste values for entire row based on cell contents

Thank you so much, Sheeloo. This works like a dream and your responses were
really quick too.

"Sheeloo" wrote:

Try this
n = Cells(Rows.Count, "q").End(xlUp).Row
For i = 1 To n
With Cells(i, "q")
If .Value = "Expired" Then
.Value = "Emailed"
Rows(i & ":" & i).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
skipBlanks:=False, Transpose:=False
End IF

End With

The way you have written it, your IF ends on the line
If .Value = "Expired" Then .Value = "Emailed"

Notice that I have moved .Value = "Emailed" to the next line and added END
IF at the end

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Paste values for entire row based on cell contents

n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
With Cells(i, "A")
If .Value = "Expired" Then .Value = "Emailed"
If .Value = "Emailed" Then
.EntireRow.Copy
.PasteSpecial xlPasteValues
End If
End With
Next

regards
FSt1

"Janelle S" wrote:

Hi all

Hoping someone can help out. I want to paste the values in the entire row
based on the contents of one cell in that row.

Column Q is "Approved Status" with formula that is either Current or
Expired. When the formula changes to expired, the user activates a macro to
send an email with the expired cases. Expired then changes to Emailed. I
would like all the cells in that row to then be copied and pasted with their
values rather than the formula that exist in the other cells. This is the
macro I have so far - thanks to Ron DeBruin:

Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007

ActiveSheet.Unprotect
Selection.AutoFilter Field:=16, Criteria1:="expired"
Rows("2:2").Select
Range("B2").Activate
Selection.EntireRow.Hidden = True


Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
Set rng =
Sheets("Approvals").Range("b3:q20").SpecialCells(x lCellTypeVisible)

On Error GoTo 0


If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If

With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "CRCs Requiring New Approvals - Please Action"
.HTMLBody = RangetoHTML(rng)
.Display
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing

Selection.AutoFilter Field:=16
Cells.Select
Range("B3").Activate
Selection.EntireRow.Hidden = False
Rows("1:1").Select
Range("B1").Activate
Selection.EntireRow.Hidden = True

ActiveSheet.Unprotect
Range("B3:U13").Select
Selection.sort Key1:=Range("Q4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal



n = Cells(Rows.Count, "q").End(xlUp).Row
For i = 1 To n
With Cells(i, "q")
If .Value = "Expired" Then .Value = "Emailed"
End With
Next


ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFiltering:=True
End Sub



  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default Paste values for entire row based on cell contents

You are welcome.

Glad it solved your problem.

"Janelle S" wrote:

Thank you so much, Sheeloo. This works like a dream and your responses were
really quick too.

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 Paste Values - Entire Workbook and Save Scott Campbell[_2_] Excel Discussion (Misc queries) 1 August 9th 07 07:53 PM
Modify Row & Cell Contents based upon Cells Values bpat1434 Excel Worksheet Functions 0 November 7th 04 03:31 PM
Modify Row & Cell Contents based upon Cells Values bpat1434 Excel Worksheet Functions 1 November 7th 04 12:43 PM
Modify Row & Cell Contents based upon Cells Values bpat1434 Excel Worksheet Functions 1 November 7th 04 03:12 AM
Modify Row & Cell Contents based upon Cells Values bpat1434 Excel Worksheet Functions 1 November 6th 04 05:17 PM


All times are GMT +1. The time now is 08:37 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"