Results 1 to 5 of 5

Relative Selection

Threaded View

  1. #1
    Registered User
    Join Date
    07-31-2019
    Location
    South Carolina
    MS-Off Ver
    Office 13
    Posts
    4

    Relative Selection

    I have a function that creates a copy of the current worksheet, renames the worksheet to the current date (MMM-YY) and changes volatile functions in certain cells to static functions to effectively freeze the data or create a snapshot. The range for the data that needs to be frozen is S8:S300.

    The worksheet formula is as follows:

    S8=INT((TODAY()-R8)/30.14) where R8 is the Start Date for an individual. This spits out an integer value for how many months a person has been in a position.

    I need my VBA sub to replace the above function with a static integer. Where S8 references R8, S10 references R10, and so on and so forth all the way to S300. Below is a copy of my "Freeze Data" sub that attempts to do this. Since I'm using a variable that does the calculation I don't know how to reference multiple ranges relative to the output ranges. I have also attached the excel sheet if any 42A's out there are lurking and want a graphical leader slate.

    Public Sub CommandButton1_Click()
        Dim newName As String
        Dim staticDate As Integer
    
        newName = Format(Date, "mmm-yy")
        staticDate = (Date - Worksheets("MAIN SLATE").Range("R8")) / 30.14
    
        If newName <> "" Then
            ''''''''Copy Main Slate''''''''
            ActiveSheet.Copy After:=Worksheets(Sheets.Count)
            ''''''''Change Copy Name to Current MMM-YY''''''''
            ActiveSheet.Name = newName
            ''''''''Deletes Freeze Data Button''''''''
            Worksheets(newName).Shapes("CommandButton1").Delete
            ''''''''Change "Time In Pos" to static Integer''''''''
            Worksheets(newName).Range("S8:S300").Value = staticDate
            ''''''''Change cell "T4" to static date'''''''''
            Worksheets(newName).Range("T4").Value = newName
        End If
    End Sub
    Any help would be appreciated. Apologies if this has been covered already as I am unsure of how to really describe the problem.
    Attached Files Attached Files
    Last edited by Pepper_; 08-02-2019 at 03:40 PM. Reason: Spelling

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Listbox selection relative to last row
    By Biffer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2015, 05:43 AM
  2. [SOLVED] Relative Selection based on column to the left
    By Shawn Michaels in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-06-2012, 12:12 PM
  3. [SOLVED] Relative Range Selection
    By Ashali in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-02-2012, 04:07 AM
  4. VBA range Selection with relative reference
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-29-2011, 12:39 PM
  5. Selection.CellTypeVisible Relative Cell Value
    By ron_oniel in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-07-2011, 07:16 PM
  6. Macro relative range selection
    By griz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-02-2008, 05:12 AM
  7. [SOLVED] Need to delete rows relative to selection
    By ratchick in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-22-2005, 12:55 PM

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