Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7741971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:09:51+00:00 2026-06-01T09:09:51+00:00

I have an Excel VBA Script I’ve written with help, I am not a

  • 0

I have an Excel VBA Script I’ve written with help, I am not a neophyte when it comes to coding, but to me so far Excel VBA has been an arsenic nightmare wrapped in a sugar pill sold by MS as a language easy to learn.

Ok, rant out of the way sorry, but I digress.

Here is the complete script:

Option Explicit

Sub tgr()

    Dim wsB As Worksheet 'BackOrder
    Dim wsJ As Worksheet 'Jobs List
    Dim wsA As Worksheet 'Archive
    Dim LastRow As Long

    Set wsB = Sheets("BackOrder")
    Set wsJ = Sheets("Jobs List")
    Set wsA = Sheets("Archive")

    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False
        .EnableEvents = False
        .Calculation = xlCalculationManual
    End With

    With Intersect(wsJ.UsedRange, wsJ.Columns("N"))
        .AutoFilter 1, "<>Same"
        With Intersect(.Offset(2).EntireRow, .Parent.Range("B:L"))
            .Copy wsA.Cells(Rows.Count, "B").End(xlUp).Offset(1)
            .EntireRow.Delete
        End With
        .AutoFilter
    End With

    LastRow = wsB.Range("B6").End(xlDown).Row
    wsB.Range("P5:Q5").Copy wsB.Range("P6:Q" & LastRow)
    Calculate
    wsB.UsedRange.Copy Sheets.Add.Range("A1")

    With Intersect(ActiveSheet.UsedRange, ActiveSheet.Columns("Q"))
        .AutoFilter 1, "<>Different"
        .EntireRow.Delete
        With .Parent
            .AutoFilterMode = False
            Intersect(.UsedRange, .Columns("G")).Cut .Range("F1")
            Intersect(.UsedRange, .Columns("H")).Cut .Range("G1")
            Intersect(.UsedRange, .Columns("L")).Cut .Range("H1")
            Intersect(.UsedRange, .Columns("N")).Cut .Range("I1")
            Intersect(.UsedRange, .Range("B:J")).Copy wsJ.Cells(Rows.Count, "B").End(xlUp).Offset(1)
            .Delete
        End With
    End With

    LastRow = wsJ.Cells(Rows.Count, "B").End(xlUp).Row
    wsJ.Range("M1:T1").Copy
    wsJ.Range("B3:I" & LastRow).PasteSpecial xlPasteFormats
    wsJ.Range("U1:W1").Copy wsJ.Range("J3:L" & LastRow)
    wsJ.Range("X1:Y1").Copy wsJ.Range("M3:N" & LastRow)

    With Application
        .Calculation = xlCalculationAutomatic
        .EnableEvents = True
        .DisplayAlerts = True
        .ScreenUpdating = True
    End With

End Sub

As you can see this is a three page script, BackOrder, Jobs List, and Archive, what I need to do is in Archive. The cells in Columns in J & K use TODAY() as a way to tell the rest of the script when it looks in the cell in column F how many days early or late it is.

Column J shows early, Column K shows late.

Column J’s script is:

=IF(F3-TODAY()<0,"",F3-TODAY())

Column K’s script is:

=IF(TODAY()-F3<1,"",TODAY()-F3)

Column F in this case is part of the larger script, which moves data via an import and has no formatting.

Now, when I bring row into Archive, I want it to be where the cells, instead of having TODAY() in either script, I want it to show the date it was moved over there, so it will still be today, but instead of TODAY(), it will have the date in this format ##/##/##. It will “freeze” the count of J & K so it will be accurate from that day forward, so we will know if it was shipped late, early, or on time.

Is this possible, and if so how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:09:52+00:00Added an answer on June 1, 2026 at 9:09 am

    You are confusing worksheet functions and VBA functions. You stopped your rant too soon although I think Word VBA is the worst version.

    With the user interface, I can go to cell A1 and type “4apr12”. Excel recognises this as a date, stores the value as 41003 and sets the format to “dd-mmm-yy” which is the standard format closest to what I typed.

    Alternately, I could type “41003” then go to the format menu and select or enter a date format of my choice.

    Yet another choice is to type “=TODAY()”. Excel stores the value as “=TODAY()” but because of the leading equals, it evaluates this as an expression when it is entered and displays the value as a standard date (format dd/mm/yy here in the UK) and re-evaluates the expression when the workbook is opened and saved and when told to do so via the Calculate options.

    VBA functions are different. Even when they do the same thing, they often have different names. The nearest equivalent to TODAY() is Now(). This function returns the current date and time as a number. The integer part is the days since 1-Jan-1900; the fraction part is (Number of seconds since midnight)/(Number of seconds in a day). So at midday today, Now() would have returned “41003.5”. This is a number; I can multiple it by two, subtract 5000 or whatever.

    With VBA, I could execute:

    Range("A1").Value = "4apr12"
    

    Excel recognises this as a date just as if I had typed it from the user interface.

    Alternatively, I could execute:

    Range("A1").Value = 41003.5
    

    This is just a number and will be stored and displayed as 41003.5.

    If I want it to be displayed as a date, I must execute:

    With Range("A1")
      .Value = 41003.5
      .NumberFormat = "dd mmm yy"
    End With
    

    The value is still saved as 41003.5 but I have told Excel to display it as 4 Apr 12.

    I can execute:

    Range("A1").Value = "=TODAY()"
    

    This is treated just as if I had typed this formula from the interface.

    But suppose I execute:

    With Range("A1")
      .Value = Now()
      .NumberFormat = "dd mmm yy"
    End With
    

    Now() returns the current date and time as a number. Excel stores it as a number but displays it as a date because I have told it to. It will never re-evaluate because it is a simple numeric value not an expression involving functions.

    I hope you this makes sense and helps you get your mind around the differences between Worksheet functions and VBA functions. Excel and VBA are like learning to drive a car. The first time you KNOW you will NEVER be able to do all these different things at the same time. Yet, a month or two later, you are playing with the pedals, the gear stick, wheel and indicator while checking the mirror. I do not understand why people think patting your head and rubbing your stomach is such as big deal. All I can say is that sudenly the mist will clear and Excel and VBA will make sense.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VBA script that inserts long strings into Excel cells. In some
I have written a VBA macro in an excel spreadsheet that opens all workbooks
I have the below SQL Script which is run from Excel VBA using ADO
Excel 2002 VBA. I have a macro that launches an external script whenever a
I have an Excel VBA Application running on Windows Vista. A .Net DLL has
I have a problem with my VBA script in Excel. What I do is
I am trying to write a VBA script in Excel 2003 (not my choice
I have a large VBA script file that references the cells of an excel
Here is a question for my Father. He has been using VBA in Excel
I'm using Excel VBA and have a worksheet_change event like so: Private Sub Worksheet_Change(ByVal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.