A Code To Refresh Internally Generated Time()
May 6, 2007In cell B9 I have a simple Time formula which can be refreshed manually through F9.
Would like a code that automatically refreshes the time every 30 seconds, if that is possible.
In cell B9 I have a simple Time formula which can be refreshed manually through F9.
Would like a code that automatically refreshes the time every 30 seconds, if that is possible.
I have thousand rows of data in the following format:
Despatched Time
Batch
Date
Time
Amended Time
20/4/2013 3:45:00
1
20/4/2013
03:45
[Code] ..........
'Date' is generated by =IF(A2="", "", TRUNC(A2))
'Time' is generated by =IF(A2="", "", IF(E2 = "", A2 - TRUNC(A2), TIME(LEFT(E2,LEN(E2)-2),RIGHT(E2,2),0)))
And sometimes I may want to change the Time, so I used another column 'Amended Time' to insert a 4-digit value to do so.
I want to arrange them into batches according to the hh:mm, so for the column 'Batch', I used the following formula:
=IF(D2 = "", "", IF(EXACT(D2, D1),MAX(B$1:B1),MAX(B$1:B1)+1))
The problem is, when I changed the time by inserting 4 digits in 'Amended Time', the time value is actually different from those generated by TRUNC(), so even two cells have the same time '03:46', the time value is not exactly the same and so they are arranged into different batches (please refer to the following table).
Despatched Time
Batch
Date
Time
Amended Time
20/4/2013 3:45:00
1
20/4/2013
03:45
[Code] ..........
I have the following code that will look through an individual worksheet, if the value in column D is equal to 5 and the value in cells E6:L1000 is "a" then it should generate an email. The problem I am having is that it generates 8 emails, one for each column. What did I do wrong in the code? It should only generate one email for the cell which has the "a"
Sub Test()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim cell As Range
Dim wsWH As Worksheet
Dim lngMax As Long
Dim intFiveDays As Integer
Application. ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error Goto cleanup
Set wsWH = Worksheets("WH")
lngMax = wsWH.Range("A65536").End(xlUp).Row
For intFiveDays = 6 To lngMax...................
Suppose that you have some data points and you want to fit a straight line to them. You write the line's equation in the cells ajacent to your data points, make the square of each difference, sum up all the squares and you have your objective function. Of course your line equation depends on two parameters, that you enter in two cells. Then you run the Excel Solver, enter your objective function as target cell to minimize, enter the range containing your parameters, set your constraints and off you go.
So far so good.
And now suppose that in order to generate your model data it is not enough to write a straight line equation in some cells, but rather to run a complete reactor model (contained in a macro). How do I couple that model-generating macro with the Excel Solver? Now, I actually found a solution. I wrote a Worksheet_change macro in the sheet containing the model parameters, which calls the model-generating code each time the parameters are chenged by the Excel Solver. This has worked fine for a simple example as the straight line one.
Now one of the two:.....
I have the following code to do something similar to above but I need to add the filepath as a hyperlink to the email along with the body text. I have 4 cells in the Excel workbook that contain 1) Who to sen to:, 2)The Subject:, 3) A sentence for the Body of the email and 4) The filepath of the workbook as a hyperlink.
I want to add both the Body text and the hyperlink to the email so that the person opening the email can click on the link and open the file.
[Code] ....
My macro appears to be refreshing the data from the queries on my supporting worksheets at the wrong time. It apparently doesn't go in the order it appears in my VBA code (and if anyone can explain that I'd love to know what's going on there).
Anyway, all I want to have happen is for all the queries to refresh, and THEN for the rest of my macro to run. So for example, if the user changes the job number in cell A1, or the Date in cell A2, I want the queries to refresh for this new information, and when that is done I want the rest of the macro to run.
I found the following code, but I don't understand enough about VBA to know where exactly it goes. Could someone please walk me through this? I tried putting in Sheet 1 under Microsoft Excel Objects, and I tried putting it in a Module, but neither worked. I'm sure it's some combo of both, but I can't figure it out.
I'm working on a monster file having a RAW DATA sheet, analysis sheets and a summary sheet which "milks" the relevant outputs into the preset table’s presentation. The point is the Milking is "alive" and not "copy/paste" like such that any new analysis is immediately summarized. It's only an 8M file but it freezes for "computing cells" every 20-30 second for about 30 seconds. This has a good potential for driving a person crazy. Any idea why is it so slow? Any way to set the update-time to longer time intervals or to update only cells which origin has been changed lately?
View 3 Replies View RelatedIn the Data tab under Connection Properties, I have "Refresh every x minutes" checked. Question is how do I capture in a cell within a sheet the last time it was refreshed?
View 2 Replies View Relatedwhat i am trying to do is...... i have a website link which i kept open. For every after 5 mins my session logsout.
is there any alternate solution or a vba code which keep refreshing the page once in 4 mins.
I want to put a macro in that will refresh the workbook before this next part of code is run:
[Code] .....
I tried putting this in before:
[Code] ....
But it isn't refreshing the workbook before the next part is run
I am writing a routine to retrieve multiple stock quotes by looping through a bunch of sheets and refreshing a bunch of querytables that access the web. My data source (Livecharts) is often clogged up and queries will fail or get lost in space so after initiating the queries I wait for a while using a waitable and then check to see if each query has completed or is still refreshing. If they are still refreshing I cancel them and refresh again. Or at least that was the plan. What I have discovered is that as long as the vba code is running the results from the queries do not come back into excel. As soon as the code is exited or I go into break mode in the debugger the queries complete.
Is there some way to get the queries to refresh during code execution? Here is a code snippet that shows what I am trying. I have defined a Class Module defining an "EventfulQTable" and it's associated methods and properties so I can have a QueryTable with events. The sub Wait uses the windows API SetWaiTable command to pause for a specified period of time. It includes a DoEvents command which I thought would allow the returning queries back into Excel but no such luck.
Sub Refresh_Queries()
Dim SheetNum As Integer, ListSheet As Integer
Dim eqtQT As New EventfulQTable
Dim QueriesDone As Boolean
SheetNum = 1
ListSheet = 12
QueriesDone = False
On Error Goto QueryError
I have written some simple VBA code so that on Sheet 4 I have a drop down list box to choose the month.
When the month is chosen by the user it moves to the active cell and changes the dates, as well as dates in some other columns (I used activecell.offset ....).
This code runs perfectly fine when I haven't refreshed the pivot tables in the workbook. But straight after a refresh, if I try and change the month it gives a run time error and gets stuck at the first instruction:
Sub cboMonth_Change()
Sheet4.Range("C2").Activate
I have 2 drop downs that when changed, auto refresh all pivot tables. My problem is getting the columns to auto-adjust based on the refresh or change of the data in the pivot table. Listed below the code I have thus far for the auto-refresh on pivot tables. How to auto expand all columns simultaneously.
The pivot tables are based off of tables on a different sheet(TOS Tables). So the code listed below is in the table sheet, not the pivot table sheet (TOS Customer Level). So followup question will be, which sheet to put the auto-expand columns code?
VB:
Private Sub Worksheet_Calculate()
'If data on this worksheet changes, refresh the pivot table
Sheets("TOS Customer Level").PivotTables("PivotTable2").RefreshTable
Sheets("TOS Customer Level").PivotTables("PivotTable5").RefreshTable
End Sub
I have some VBA code which hides columns based on a cell value. The cell value changes according to which option button is selected. The code works but not when the button is selected and the cell value changes. It is necessary to click elsewhere in the sheet or press Enter to get the columns to hide. I want it to do it automatically as a user wouldn't know to click elsewhere.
The working code is:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("N5").Value = 2 Then
Columns("O:R").EntireColumn.Hidden = True
Else
Columns("O:R").EntireColumn.Hidden = False
End If
End Sub
N5 is the linked cell for the option button.
I have a query with ODBC connection to a SQL database. This query's parameter is linked to a cell. The resultant data is the source for a pivot table. I want to refresh the pivot table, when the query is run. I've tried using the cell that triggers the query....but the problem is that the query takes about 10 seconds to run. By the time the query returns new data....the pivot has already refreshed. I need it to refresh AFTER the query is complete.
I tried adding a cell that sums up the data from the query...thinking when THAT changes (due to updated data), to trigger the pivot refresh. Problem is that I don't know the trigger for when the sum cell changes (ie....formula change, not typed in.)
i have an excel spreadsheet with 27 or so workeets. it contains sales figures in it.
I want to be able to link mutiple cells of this workbook to another workbook so that it retreives that data, So that when I hit the refresh (!) button it will automatically put the data in. I will recieve new sales figures (new files) on a monthly basis so i want it to be able to update the figures to the new figures.
I've got a spreadsheet with a few queries to extract data into my sheet. Whenever I open the spreadsheet, I get a "query refresh" dialog box, asking if I want to "Enable automatic refresh". I keep clicking on the "Enable" button but I have to keep answering the question for each open. Isn't there a way to set "yean - ok - refresh the data" so that I don't have to keep saying "yes"?
View 2 Replies View RelatedWill someone please tell me the difference (if there is a difference) between the following 2 lines of ....
View 6 Replies View RelatedI’m creating a spreadsheet to control corrective actions. Each corrective action will have a date that it needs to be completed by. When the completion date plus one day is passed, I need the cell that the completion date is in, to turn a specific colour and a warning mail to be sent via outlook When a further six days have passed I need the cell to turn a different colour again and another email is sent
Ive generated the following code to call an Outlook subroutine if the correct conditions are met. The subroutine runs ok but I can get the sheet code to run.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("A1"), Target) Is Nothing Then
If IsDate(Target.Value) And Now() = Target.Value + 1 Then
Target.Interior.ColorIndex = 3
Call Mail_with_outlook
ElseIf IsDate(Target.Value) And Now() = Target.Value + 6 Then
Target.Interior.ColorIndex = 5
Call Mail_with_outlook
End If
End If
End Sub
I'm trying to sort some data that is generated from a PDF. When I copy the PDF into Excel all of the data is placed into one cell. Is there a function or formula I can use in VBA or within the spreadsheet to accomplish this?
For example, the cell may contain "Employee John Employee Steve Employee Dave Employee Jed Employee Mark" in cell A1. I want the function to list John, Steve, Dave, Jed and Mark in separate cells. So I need to get rid of the space bar hits, the word employee and to separate the names to different cells.
A1 currently is "Employee John Employee Steve Employee Dave Employee Jed Employee Mark"
I would like to create a formula to have cells:
A2 = John
A3 = Steve
A4 = Dave
A5 = Jed
A6 = Mark
I wish to create a new sheet/workbook which promts the user to enter a start number and an end number. I want to then display 20% of randomly picked numbers between the start and end figures.
For example, the user enters 1 as a start and 20 as an end figure. 20% of this is 4, hence I want the system to randomly return 4 numbers between 1 and 20.
We are having a sporadic issue throughout our company where when users attempt to open an ASP generated spreadsheet in Internet Explorer and then hit CTRL+A to copy all contents and attempt to paste into a regular Excel-launched spreadsheet (i.e. launching Excel independent of IE), the last two columns are not being copied. Further, when attempting to just copy the two columns, themselves, only the first is copied, and when attempting to copy one cell each in the two columns (that are in the same row), only the first cell is copied. Additionally, when examining the clipboard in this instance, only the first cell is being copied to the clipboard, so for some reason attempting to copy it out of the Excel spreadsheet that opens in IE is when the issue occurs (vs. having the issue occur when you are trying to copy into the new Excel spreadsheet from the clipboard).
View 6 Replies View RelatedI am have some code that takes values from a range (sourceAll) defined on my worksheet as:
Set sourceAll = Workbooks(pathnm).Worksheets(m).Range("A1", "S34")
I'd now like to be able for the range to be generated dynamicaly, but my problem is that the far right column (S) does not always have a value for every entry. Is there a way of using a column that does have a value for every entry, say column B, but then extending the range accross to S? If possible I'd like to avaoid having to move one of the columns with values for every entry. Auto Merged Post;I was looking at some of the suggested threads and found some code that I worked into my own
Set countRow = Workbooks(pathnm).Worksheets(m).Range("B1250").End(xlUp)
Set sourceAll = Workbooks(pathnm).Worksheets(m).Range("A1", countRow)
sourceAll = sourceAll.Resize(sourceAll.Rows.Count, sourceAll.Columns.Count + 17)
now this seems to work mostly, but it has deleted everything that was in column B.
I have a file here that already has macros in it. The file is basically a excel document generator. When you click create sku, the document will generate multiple documents based on the user inputs.
1) In the generated documents the original "generator" file creates, I need generated files to have column B and D formatted to TEXT, currently all the generated files are formatted to general. (This code is in module 1, line 84 col 34.)
2) The other problem is I need to append the value in Cell N1 in the "sku data entry" sheet to be appended to the generated file names. (this part of the code is is in module 1, line 150 col 28.)
I was unable to attach my file to this thread because it was to big. however I copied the module where I think the code is causing problems:
Sub procData()
' Starting point for read/extract process
Cells(4, 6).Select ' Range = F4 (row 4, col 6)
For x = 6 To 52 Step 2 ' col F to col AZ
[Code]...
I have a schedule sheet (on week days what assignment is be to taken in concerned period).
I need a report based on the same. i.e. I need to generate a report for each individual.
I have attached a sample file, in which I explained the requirements.
Prior to Excel 2007, the functions provided by the Analysis Tool Pack (ATP) are provided by a separate add-in. You cannot call them using the methods shown above. First, you must load the Analysis Tool Pack - VBA add-in. Note that this is different from the Analysis Tool Pack item. Once this add-in is loaded, go to VBA, open your project, and choose References from the Tools menu. In that dialog, choose atpvbaen.xls in the list of references. Once you have that reference in place in your VBA code, you can call the functions in the ATP as if they were native VBA functions.
View 8 Replies View RelatedI have written the VBA code to color any figure above 15, but it display rows above 15 as red including other rows.
Below is the VBA code
Code:
Sub FillCells()Dim lRow As Long, lColumn As Long
'Using Cells property to refer to range
'Loop through rows
For lRow = 1 To 10
'Loop through columns
For lColumn = 1 To 5
[code].....
Which shows the output as Workbook1.jpg But my query is how to get only rows above 15 with red color
In my worksheet in column CC in C1:C20 I want Excel to ganerate 20 random numbers between 1 and 80 without repeating the same numbers.
At present I have the following formula entered and it works, but after I click F9 some repeated numbers are generated.
=INT(RAND()*(80-1)+1)
How can I change the formula or replace it?
how to use the random number generator to generate unique numbers (1-55) based on the odd percentages in the attached chart.
for example in the chart, chances 1 through 10 are more likely to be generate first rather then the last chance number 55 based on the draft pick odds....
Is there a way to control the number generation. I would like to be able to run different scenarios with the same set of random numbers, then regenerate the random numbers and do it again. Right now every time I do anything in the spreadsheet, I get a new set of numbers.
View 4 Replies View Related