+ Reply to Thread
Results 1 to 3 of 3

ActiveCell Format Same as Target.Address Format

Hybrid View

  1. #1
    Paige
    Guest

    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. #2
    K Dales
    Guest

    RE: 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. #3
    Paige
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1