Results 1 to 4 of 4

VBA Code for Going Back to Previous Active Cell!

Threaded View

  1. #1
    Forum Contributor
    Join Date
    01-07-2012
    Location
    Bangalore
    MS-Off Ver
    Office 365
    Posts
    368

    VBA Code for Going Back to Previous Active Cell!

    Dear Friends,

    Need your support on subjected Query: -

    Please refer below code which is working completely fine for me, Except where Red Highlighted!!!

    ActiveCell.Row & ActiveCell.Column goes to next Row or next Column based on User Press Tab or Enter Respectively after entry in a current cell!

    Requesting you to provide your valuable suggestion, How to Select previous active cell in both the cases, so that it extracts right value from “Data” sheet and paste in “LogDetails” sheet!

    Dim Oldvalue As String
    
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
        If Sh.Name = "Data" Then
            If Not Intersect(Target, Sh.Range("AO2:EE1000")) Is Nothing Then
                Application.EnableEvents = False
                With Worksheets("LogDetails")
                    .Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = UCase(Environ("username"))
                    .Range("A" & Rows.Count).End(xlUp).Offset(0, 1).Value = Format(Now, "DD-MMM-YYYY HH:MM:SS")
                    .Range("A" & Rows.Count).End(xlUp).Offset(0, 2).Value = Cells(ActiveCell.Row, "AN").Value
                    .Range("A" & Rows.Count).End(xlUp).Offset(0, 3).Value = Cells(1, ActiveCell.Column).Value
                    .Range("A" & Rows.Count).End(xlUp).Offset(0, 4).Value = Oldvalue
                    .Range("A" & Rows.Count).End(xlUp).Offset(0, 5).Value = Target.Value
                End With
            End If
        End If
        Application.EnableEvents = True
    End Sub
    
    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Oldvalue = Target.Value
    End Sub
    Thanks & Regards,
    Rajeshkumar R
    Last edited by Rajeshkumar R; 10-18-2017 at 03:08 PM. Reason: Query Resolved

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Highlight active row but after leaving it give its previous color back
    By ImranBhatti in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-18-2017, 10:36 AM
  2. Changing Background Color for Active Cells, then back to Previous Color...
    By TMCinDC in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-13-2016, 11:35 AM
  3. Go back to previous active sheet
    By gopal baheti in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-02-2014, 09:43 PM
  4. [SOLVED] back to previous active sheet ?
    By Lukael in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2014, 04:45 PM
  5. [SOLVED] Code to detect previous active workbook instead of current active workbook
    By kosherboy in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-25-2014, 01:58 AM
  6. [SOLVED] Go back to previous active sheet (Excel 2007)
    By JawD in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-09-2012, 08:00 AM
  7. VBA code to open next sheet or go back to previous
    By ABSTRAKTUS in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-14-2010, 07:21 AM

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