Results 1 to 7 of 7

Macro that converts today()+3 in to text on 2 columns

Threaded View

  1. #1
    Registered User
    Join Date
    12-07-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    10

    Macro that converts today()+3 in to text on 2 columns

    Hi all,

    I had a perfectly working macro for 1 column which when the work sheet is saved, the macro converts any formulas on a column that has today()+3 in, into a text, so when it saves, the date remains static.

    I now need this macro to do the same job within 2 columns, however, it fails to pick up on the second column. This is my macro so far:

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim cell As Range, cell2 As Range, DateRng As Range, DateRng2 As Range
    
    Set DateRng = Sheets("January").Range("L5:L36665")
    Set DateRng2 = Sheets("January").Range("B5:B36665")
    For Each cell In DateRng
    If IsDate(cell.Value) Then
        cell.Copy
        cell.PasteSpecial Paste:=xlPasteValues
    End If
    Next cell
    
    For Each cell2 In DateRng2
    If IsDate(cell2.Value) Then
        cell2.Copy
        cell2.PasteSpecial Paste:=xlPasteValues
    End If
    Next cell2
    
    End Sub
    Any help would be greatly appreciated it.

    The original macro that works perfectly on 1 column is:
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim cell As Range, DateRng As Range
    
    Set DateRng = Sheets("January").Range("L5:L36665")
    For Each cell In DateRng
    If IsDate(cell.Value) Then
        cell.Copy
        cell.PasteSpecial Paste:=xlPasteValues
    End If
    Next cell
    
    End Sub
    Last edited by phish3rz; 12-28-2012 at 05:56 AM. Reason: Solved!

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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