Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default format on change event

i received some helpful code that upon change of a cell in one tab, the row
is moved to another tab. is it possible to preserve the formatting of the
row in the move to the next tab? i would think this would be relatively
simple, but cant seem to come close to getting it to happen (the row is 5
columns long, with a thin outline around each cell and wrapped text in the
last column).

if the above is not possible, i thought that this might work (formatting the
row in the new tab after the move has taken place), but im not sure where i
am going wrong.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo stoppit
Application.EnableEvents = False



If Target.Column = 5 And Target.Row 2 And Target.Value < "" Then
With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp)
.Offset(1, 0).EntireRow = Target.EntireRow.Value
End With

Target.EntireRow.Delete



With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).WrapText = True
End With

MsgBox Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).Address

End If
stoppit:
Application.EnableEvents = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default format on change event

revised the code as follows; but still cant seem to get the wrapping to work

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo stoppit
Application.EnableEvents = False



If Target.Column = 5 And Target.Row 2 And Target.Value < "" Then
With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp)
.Offset(1, 0).EntireRow = Target.EntireRow.Value
End With

Target.EntireRow.Delete

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(1, 5).Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With


With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).WrapText = True
End With


End If
stoppit:
Application.EnableEvents = True
End Sub


"joemeshuggah" wrote:

i received some helpful code that upon change of a cell in one tab, the row
is moved to another tab. is it possible to preserve the formatting of the
row in the move to the next tab? i would think this would be relatively
simple, but cant seem to come close to getting it to happen (the row is 5
columns long, with a thin outline around each cell and wrapped text in the
last column).

if the above is not possible, i thought that this might work (formatting the
row in the new tab after the move has taken place), but im not sure where i
am going wrong.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo stoppit
Application.EnableEvents = False



If Target.Column = 5 And Target.Row 2 And Target.Value < "" Then
With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp)
.Offset(1, 0).EntireRow = Target.EntireRow.Value
End With

Target.EntireRow.Delete



With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).WrapText = True
End With

MsgBox Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).Address

End If
stoppit:
Application.EnableEvents = True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default format on change event

I think copy-paste is the easiest way to do it: (unmarked lines are my changes)

This is what I used, and would like to hear if an easier way is possible.

Best,

If Target.Column = 5 And Target.Row 2 And Target.Value < "" Then
With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp)

Target.EntireRow.Copy
.Offset(1, 0).EntireRow.PasteSpecial xlPasteAll,
PasteSpecialOperationNone
End With

Target.EntireRow.Delete

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(1, 5).Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With


With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).WrapText = True
End With


End If
stoppit:
Application.EnableEvents = True
End Sub


"joemeshuggah" wrote:

i received some helpful code that upon change of a cell in one tab, the row
is moved to another tab. is it possible to preserve the formatting of the
row in the move to the next tab? i would think this would be relatively
simple, but cant seem to come close to getting it to happen (the row is 5
columns long, with a thin outline around each cell and wrapped text in the
last column).

if the above is not possible, i thought that this might work (formatting the
row in the new tab after the move has taken place), but im not sure where i
am going wrong.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo stoppit
Application.EnableEvents = False



If Target.Column = 5 And Target.Row 2 And Target.Value < "" Then
With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp)
.Offset(1, 0).EntireRow = Target.EntireRow.Value
End With

Target.EntireRow.Delete



With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).WrapText = True
End With

MsgBox Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).Address

End If
stoppit:
Application.EnableEvents = True
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default format on change event

i believe i have solved my dilema (used resize incorrectly)...here is my
revised code


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo stoppit
Application.EnableEvents = False



If Target.Column = 5 And Target.Row 2 And Target.Value < "" Then
With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp)
.Offset(1, 0).EntireRow = Target.EntireRow.Value
End With

Target.EntireRow.Delete

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(1, 5).Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With


With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).WrapText = True
End With


End If
stoppit:
Application.EnableEvents = True
End Sub


"Hakyab" wrote:

I think copy-paste is the easiest way to do it: (unmarked lines are my changes)

This is what I used, and would like to hear if an easier way is possible.

Best,

If Target.Column = 5 And Target.Row 2 And Target.Value < "" Then
With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp)

Target.EntireRow.Copy
.Offset(1, 0).EntireRow.PasteSpecial xlPasteAll,
PasteSpecialOperationNone
End With

Target.EntireRow.Delete

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(1, 5).Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With


With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).WrapText = True
End With


End If
stoppit:
Application.EnableEvents = True
End Sub


"joemeshuggah" wrote:

i received some helpful code that upon change of a cell in one tab, the row
is moved to another tab. is it possible to preserve the formatting of the
row in the move to the next tab? i would think this would be relatively
simple, but cant seem to come close to getting it to happen (the row is 5
columns long, with a thin outline around each cell and wrapped text in the
last column).

if the above is not possible, i thought that this might work (formatting the
row in the new tab after the move has taken place), but im not sure where i
am going wrong.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo stoppit
Application.EnableEvents = False



If Target.Column = 5 And Target.Row 2 And Target.Value < "" Then
With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp)
.Offset(1, 0).EntireRow = Target.EntireRow.Value
End With

Target.EntireRow.Delete



With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).WrapText = True
End With

MsgBox Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).Address

End If
stoppit:
Application.EnableEvents = True
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default format on change event

I have questions for you at the original thread but I'll ignore that thread
now that you have posted here.

Why have you started a new thread?

Just fragments replies.

Here is some revision of the helpful code that you did not care to attribute
to originator.

Private Sub Worksheet_Change(ByVal target As Excel.Range)
Dim rng1 As Range
Dim rng2 As Range
Set rng1 = Me.Range("A1").EntireRow
Set rng2 = Worksheets("Sheet2").Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)
If target.Address = "$A$1" And target.Value < "" Then
On Error GoTo stoppit
With Application
.ScreenUpdating = False
.EnableEvents = False
rng1.Copy Destination:=rng2
rng1.Delete
stoppit:
.EnableEvents = True
.ScreenUpdating = True
End With
End If
End Sub


Gord Dibben MS Excel MVP

On Wed, 17 Mar 2010 07:53:01 -0700, joemeshuggah
wrote:

i received some helpful code that upon change of a cell in one tab, the row
is moved to another tab. is it possible to preserve the formatting of the
row in the move to the next tab? i would think this would be relatively
simple, but cant seem to come close to getting it to happen (the row is 5
columns long, with a thin outline around each cell and wrapped text in the
last column).

if the above is not possible, i thought that this might work (formatting the
row in the new tab after the move has taken place), but im not sure where i
am going wrong.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo stoppit
Application.EnableEvents = False



If Target.Column = 5 And Target.Row 2 And Target.Value < "" Then
With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp)
.Offset(1, 0).EntireRow = Target.EntireRow.Value
End With

Target.EntireRow.Delete



With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Resize(0, 5).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).WrapText = True
End With

MsgBox Sheets("Account-Specfic Explanations").Cells(Rows.Count,
"A").End(xlUp).Offset(0, 4).Address

End If
stoppit:
Application.EnableEvents = True
End Sub


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
apply cell change event to single column - WorksheetChange Event [email protected] Excel Programming 6 May 4th 08 02:28 AM
Event Macro - On Cell Activate - Change Cell Format [email protected][_2_] Excel Programming 7 November 7th 07 03:36 AM
Trigger Event on Format Change Zone[_3_] Excel Discussion (Misc queries) 4 August 25th 07 05:43 PM
event triggered by cell format change? Stefi Excel Programming 4 January 10th 06 12:35 PM
Format Painter and Worksheet Change Event Gap Excel Programming 1 February 28th 05 07:09 PM


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

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

About Us

"It's about Microsoft Excel"