Determine Date System Of Workbook In Which Macro Resides
Oct 24, 2007
I have written a few macros, which use date type variables. Because VBA uses the 1900 date system, and some workbooks use the 1904 date system, I have to first check and see if a workbook uses the 1904 date system, and if so, subtract off 1462 days where appropriate. My macros used to check the date system by using the command:
If ( ActiveWorkbook.Date1904 = True) Then
nh_stringToDate = nh_stringToDate - 1462
End If
But, sometimes the macro resides in one workbook (call it macro.xls) but the currently active workbook is some other workbook (something.xls). What I really care about is the date system of macro.xls and NOT something.xls. So, instead of "ActiveWorkbook" is there some other object I can use to refer to the workbook in which the macro itself resides? I don't want to rely on using the name of the macro workbook (macro.xls) because this could change! So I need a way to simply refer to the workbook in which the macro resides.
View 2 Replies
ADVERTISEMENT
Sep 9, 2009
I am wondering where does the Personal Macro Workbook resides. I am using Microsoft Office Excel 2007 I checked in XLStart it is not there.
View 5 Replies
View Related
Sep 7, 2007
I am looking for a macro that will run on worksheet activation. it needs to run only if the file had been saved from the previous week. would something like this work?
Private Sub Worksheet_Activate()
If application.worksheet.lastsaved = msolastweek Then
range("RANGE").clearcontents
End If
End Sub
View 7 Replies
View Related
May 6, 2009
i just want to generate a list validation where source resides in another workbook?
i have used named range concept ?but not working can anyone help..
View 9 Replies
View Related
Sep 18, 2007
I need to select a worksheet from another workbook.
I want use a cell contains which contains a date that corresponds to the worksheet's name in the other workbook.
View 4 Replies
View Related
Nov 21, 2012
I am thinking of commanding macro to select worksheet tab based on the system date to do some pasting.
My worksheet tab is as follow:
Nov-12, Dec-12, Jan-13, Feb-13 and .........
What should be the macro script required to select the worksheet tab based on today's date?
View 2 Replies
View Related
Nov 7, 2006
I'm trying to write a batch file that connects to a database and passes in an SQL query. One of the conditions of this query is the date. I need the batch file to figure out what todays date is and pass that in.
This is what I currently have.
ws_tran_date between to_date( '&datefrom 08:30:00AM', 'DD-MON-YYYY HH:MI:SS AM') and TO_DATE('&dateto 08:30:00am', 'DD-MON-YYYY HH:MI:SS AM')
When I run the batch file, it asks me to input the dates manaully in the format DD-MON-YYYY (eg 7-NOV-2006). I need the batch file to figure this out on it's own.
Is there some function I can call to do this?
View 5 Replies
View Related
Mar 26, 2008
I have a sheet that has a macro on it, I would like to run that macro programaticaly but Im not able to call it using Call mymacro type of code. The code that calls the macro resides in a module and the macro is in a sheet. Obviously they are not talking, is there a way to run it remotely without moving the macro into the module?
View 9 Replies
View Related
Mar 28, 2012
I've been using the following code and would like to add another IF that checks the value of a cell to see if it holds today's date.
Code:
If Range("E" & CStr(LSearchRow)).Value "Closed" Then
If Range("E" & CStr(LSearchRow)).Value "Closed w/o Customer Confirm" Then
'Select SR in Sheet to update
Range("B" & CStr(LSearchRow)).Select
[Code] ......
I tried to modify it to...
Code:
If Range("E" & CStr(LSearchRow)).Value "Closed" Then
If Range("E" & CStr(LSearchRow)).Value "Closed w/o Customer Confirm" Then
If Range("AK" & CStr(LSearchRow)).Value "=today()" Then
'Select SR in Sheet to update
[Code] ......
I've tried a couple of other things but no success
View 5 Replies
View Related
Mar 19, 2012
how can i count the positive days to a inserted date value or the past days (negative value) to the system date (today).
View 5 Replies
View Related
Jun 5, 2009
I'm working on a spreadsheet which needs to refer to the current date. My PC checks the system date/time daily. Can I assume that if an end-user regularly connects to the internet, their PC will have a correct system date? Does anyone know if Win2000 or Win98 automatically update the system date/time when connected to the internet?
View 4 Replies
View Related
May 25, 2007
I have created a workbook for a quality check and it has about 50+ worksheets in the workbook, which contains data, formula,graphic & vba function. The size of the file is about 4890kb. It's works as planned, except, it takes about 1 mins ++ to load, save & even exit. Is there any suggestion to eliminate this issue, apart from creating a few workbook to accomodate the number of sheets/item in the project?
View 2 Replies
View Related
Jan 30, 2009
How do you convert a range of dates in this format: 39843 (i.e today 30th of Jan 2009). To text like: 20080130. Secondly, For the same date, how do you make the weeknum function give answer '05' and not just '5'
View 2 Replies
View Related
Nov 17, 2009
I am currently using Excel 2007 and I am looking for an easier way to enter the system date and time into a cell. I am aware of the MS-Excel shortcuts but work in an environment where data capturers still often get it wrong.
Is it possible to use a Excel function/button to auto insert the system date and time by clicking on a cell/button or Alternatively use a calendar to do so.
View 10 Replies
View Related
Dec 5, 2006
i woul like to make a macr which will check the system date on the computer to see what month it is and the populate cells A14 - A44 with the dates from the 1st till the end of the month.
View 9 Replies
View Related
Mar 5, 2008
how I could have a range of B15-F15 to place Today's System-date in the Cell: A1, anytime anything is entered in that range?
View 9 Replies
View Related
Jan 23, 2009
I have the formula where i can change a date to its equivalent in terms of quarters system with a date:
=CHOOSE(MATCH(MONTH(A2),{1,4,7,10}),"Winter","Spring","Summer","Fall")&YEAR(A2)
This is a school year configuration.
ex.
A2 = 10/1/2005: with the formula up there it turns into Fall 2005
i want to be able to add any number of years and the formula will still come up with the quarters system
also i would like A2 to be stationary and create a list of quarters for each year i add on
ex.
A2= 10/1/2005 B2=Fall 2005
B3=Winter 2006
B3=Spring 2006
B5=Summer 2006
B6=Fall 2006
etc.
If this is all possible lastly I would like to negate summer quarters
View 9 Replies
View Related
Dec 12, 2007
I need to develop a System using Macro in MS Excel 2007.. but i don't know how to do it..
I got 2 file in MS Excel
File number 1 : Demand - file name : ( got 55675 row of data)
File number 2 : Supply - file name : ( got 6774 row of data )
File number 1 : The data is starting from 0110111101 ( commodity code ) until 9999999999 ( commodity code )
File number 2 : The data is starting from 1532423007(commodity code) until 9119199901 (commodity code )
I need to categorize all this data in 10 sheet ( sort by the first 2 digit of the commodity code ):
Sheet 1 : 00 -09
Sheet 2 : 10- 19
Sheet 3 : 20 - 29
Sheet 4: 30- 39
Sheet 5: 40 - 49
Sheet 6 : 50 - 59
Sheet 7 : 60 - 69
Sheet 8 : 70- 79
Sheet 9 : 80- 89
Sheet 10 : 90 - 99
View 14 Replies
View Related
Jan 7, 2009
I have no experience with macros at all but i need to create a macro for work that will keep the original data entered but work out the difference between new data collected each day ...
View 10 Replies
View Related
Oct 19, 2008
If I have a multiple workbooks open and I want to determine if a workbook is open for example "Test 1.xls", how would I do that. I want it to msgbox once to say "open" if open or msgbox "not open" if not open.
View 2 Replies
View Related
Nov 29, 2013
I cannot cut and paste from my working computer to the internet access computer.
This code is intended to check for a workbook already open and if it contains a particular worksheet. This function is called from a routine that reads a master workbook then opens a PCM workbook. The PCM workbook might already be open.
WB_PCM is declared as a workbook and the name is set. WS_PARAMETERS is declared as a string and its name is set to an existing worksheet. The workbook and worksheet do exist, but are not open.
This is the call to the function:
Code:
WS_exists = Is_Workbook_Open( WB_PCM, WS_PARAMETERS_NAME )
And that code is
Code:
Public Function Is_Workbook_Open( workbook_ref As Workbook, sheet_name As String) as Boolean
Dim check_sheet as Worksheet
On Error Resume Next
If( workbook_ref Is Nothing ) Then
Is_Workbook_Open = False
Else
Set check_sheet = workbook_ref.Worksheets( sheet_name ) ' < error
[code].....
During this time the master workbook is open but either not in focus or is minimized within the Excel windows. If I select that worksheet and select a cell in it, then this code runs. What should I do different to get this code to check for WB_PCM being open and being able to handle it when either open or not open.
View 3 Replies
View Related
Sep 8, 2006
Is it possible to write code that can identify how a workbook has been opened i.e. has the workbook been opened by another workbook or has it received a double click event on the workbook itself.
If it is possible I would like to place the code in the open event of the workbook that is being opened.
View 5 Replies
View Related
Sep 10, 2007
Trying to determine who has a file open, the code below works for simple files. However if the workbook contains macros and user forms it seems there are multiple occurances of the search terms strFlag1, strFlag2. How can I determine the last user
Function LastUser(path As String)
Dim text As String
Dim strFlag1 As String, strflag2 As String
Dim i As Integer, j As Integer
strFlag1 = Chr(0) & Chr(0)
strflag2 = Chr(32) & Chr(32)
Open path For Binary As #1
text = Space(LOF(1))
Get 1, , text
Close #1
j = InStr(1, text, strflag2)
i = InStrRev(text, strFlag1, j) + Len(strFlag1)
LastUser = Mid(text, i, j - i)
End Function
Above code taken from Determine Last User
View 2 Replies
View Related
Jan 1, 2008
I was wondering how i can code a if then loop to determine if a workbook by the name i specify is opened.
If Windows(vCriteria & "ISPR.XLS"). = True Then
MsgBox "true", vbCritical, "Ferguson Enterprises, Inc."
Else
MsgBox "false", vbCritical, "Ferguson Enterprises, Inc."
End If
thats what i got.... not sure if that will work... i'm missing the definition for: If Windows(vCriteria & "ISPR.XLS"). i keep wanting to type isopened, but alas it is not avaliable in the list. There seems to be no extention avaliable that appears to work with such a function. Is it possible to do what i am trying to do?
View 2 Replies
View Related
Apr 18, 2008
I have an excel template spreadsheet which auto loads the following when i open it:
Userform1.Show
Usreform2.Show
Application.Dialogs(xlDialogSaveAs).Show
I enter data into the userforms and save as a normal .xls file.
If i then open the .xls the auto open kicks in and opens the userforms and xlDialogSaveAs again.
How do i just get rid of all macros or vba code when i save as a .xls file so nothing auto loads.
View 3 Replies
View Related
Jun 14, 2013
I export raw data from my accounting system each month that I then format for use in another application that uses the data to produce customer statements. I have attached a file that shows the raw data in the first sheet and the formatted data in the second sheet. I recorded a macro while I did the process but I need to change the code to deal with dynamic data as the number of rows may be different every month.
Here are the steps I go through:
1. Clear the first 3 rows and the last 5 rows
2. Copy the totals in the last row of the data and paste them in the first row
3. Subtotal the different categories in row 2 and add a validity check
4. Add a new column A with a formula to add customer numbers on each line
=IF(ISERROR(FIND("00000",B5)),A4,B5
5. Copy the formulas and paste values over them
6. Filter the data to show blanks under the "Doc Date" column, delete all rows
7. Filter the data to show blanks under the "Type" column, delete all rows
8. Filter the data to show "Total:" under the "Apply No" column, delete all rows
9. Turn off filters, format all numbers in accounting format
10. Check the validation at the top to ensure no transactions were deleted
View 6 Replies
View Related
Jan 29, 2007
I've been using the following bit of code to run a macro at the specified time:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Application .OnTime TimeValue("12:00:00"), "GetData"
End Sub
The GetData sub executes a shell script and then pulls data from the result. The problem is that the macro runs 140+ times, and so I get 140 windows popping up and the system practically stops. I can't figure out why this is happening, as there are no loops or any sort of repetition in the code. Any help is greatly appreciated as this problem occurs with more than just the one spreadsheet.
View 9 Replies
View Related
Aug 6, 2009
Is there anyway I can test / inspect a file before attempting to open it to check that it is indeed an Excel workbook?
I don't want to do it by file extension as that can / will be changed, but rather wondered if there was anyway to examine the ACTUAL file?
I'm wondering if all Excel workbook files start with a particular section of data or anything?
View 5 Replies
View Related
Apr 6, 2008
Split from Macro To Insert Rows In Protected Worksheet. I have found this code wgich appears to be very close to what i want. Just to re-iterate -
A) i want to detect if any other user has the shared book open, if yes-display msg and exit - it seems to do this by just adding an appropriate msg box
B) if no - open it and lock other users out by temporarily remving share or allowing them in but as read only - not sure if it does that.
Also not sure if it works for a shared file - cannot test as i do not have access to shared network from location.
Function IsFileOpened(StrFilePath As String) As Integer
Dim FileNum As Integer
'First check filepath exists
If Len(Dir(StrFilePath)) > 0 Then
FileNum = FreeFile()
On Error Resume Next
Open StrFilePath For Input Lock Read As #FileNum ' Open file and lock it.
If Err.Number <> 0 Then
IsFileOpened = 1 'File open
Else
IsFileOpened = 0 'File Closed
End If
Close FileNum
Else
IsFileOpened = 2 'File not found
End If
End Function
View 2 Replies
View Related
Sep 21, 2013
I thought about using it for forecasting purposes. I might try to use it together with live data (temperature, seasonal patterns)... but if I graph it, it starts from left to right...
How to modify the code a bit...
VB:
Shift:=xlUp, CopyOrigin:=xlFormatFromRightOrDown
I tried to change the code, but it did not worked.
View 8 Replies
View Related