Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default ActiveCell Format Same as Target.Address Format

I'm using code where every time a user makes a change anywhere on a specific
sheet, it records that change on another (hidden) sheet. What can I add to
my code (copy of which is below) so that the new value that is entered will
show up on the hidden sheet formatted the same way (i.e., either as text, 1
decimal, 2 decimals, etc.)?

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("$A$17:$U$25")) Is Nothing Then
With Worksheets("Rates-History")
.Activate
.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Activate
ActiveCell.Value = Target.Value
End With
End If

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default ActiveCell Format Same as Target.Address Format

It would be easier to do a copy.pasteSpecial:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("$A$17:$U$25")) Is Nothing Then
Target.Copy
With Worksheets("Rates-History").(Rows.Count, "A").End(xlUp).Offset(1, 0)
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
End With
Application.CutCopyMode = False
End If

End Sub

--
- K Dales


"Paige" wrote:

I'm using code where every time a user makes a change anywhere on a specific
sheet, it records that change on another (hidden) sheet. What can I add to
my code (copy of which is below) so that the new value that is entered will
show up on the hidden sheet formatted the same way (i.e., either as text, 1
decimal, 2 decimals, etc.)?

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("$A$17:$U$25")) Is Nothing Then
With Worksheets("Rates-History")
.Activate
.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Activate
ActiveCell.Value = Target.Value
End With
End If

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default ActiveCell Format Same as Target.Address Format

Works great - thanks!

"K Dales" wrote:

It would be easier to do a copy.pasteSpecial:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("$A$17:$U$25")) Is Nothing Then
Target.Copy
With Worksheets("Rates-History").(Rows.Count, "A").End(xlUp).Offset(1, 0)
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
End With
Application.CutCopyMode = False
End If

End Sub

--
- K Dales


"Paige" wrote:

I'm using code where every time a user makes a change anywhere on a specific
sheet, it records that change on another (hidden) sheet. What can I add to
my code (copy of which is below) so that the new value that is entered will
show up on the hidden sheet formatted the same way (i.e., either as text, 1
decimal, 2 decimals, etc.)?

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("$A$17:$U$25")) Is Nothing Then
With Worksheets("Rates-History")
.Activate
.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Activate
ActiveCell.Value = Target.Value
End With
End If

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
What formula will copy the content & format of the target cell? razorman Excel Discussion (Misc queries) 2 May 11th 07 08:24 PM
ActiveCell.Value changes with Format? Sige Excel Programming 7 September 23rd 05 01:42 PM
How can i get activecell address Bond S.C Excel Programming 7 August 1st 05 10:24 AM
Activecell address Patty2005[_4_] Excel Programming 2 August 7th 04 03:58 AM
ActiveCell.Address Todd Huttenstine Excel Programming 3 July 27th 04 04:45 PM


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