VB Macro To Create SQL
Sep 11, 2007
I have the following SQL: and I don't know how to have the VB Macro change the last parameter ((A_COMPL_SUMMARY.INCIDENT_NUMBER In (?))):
SELECT DISTINCT A_COMPL_SUMMARY.INCIDENT_NUMBER, A_COMPL_SUMMARY.CASE_NUMBER, A_COMPL_SUMMARY.PART_SEQUENCE, A_COMPL_SUMMARY.PART_NUMBER, A_COMPL_SUMMARY.LOT_NUMBER, A_COMPL_SUMMARY.ALERT_DATE, A_COMPL_SUMMARY.ENTRY_DATE, MDR_REPORTING.EVENT_DESC
FROM CHSUSER.A_COMPL_SUMMARY A_COMPL_SUMMARY, CHSUSER.INCIDENT_NOTIFICATION INCIDENT_NOTIFICATION, CHSUSER.MDR_REPORTING MDR_REPORTING
WHERE MDR_REPORTING.CASE_NUMBER = A_COMPL_SUMMARY.CASE_NUMBER AND MDR_REPORTING.INCIDENT_NUMBER = A_COMPL_SUMMARY.INCIDENT_NUMBER AND MDR_REPORTING.PART_SEQUENCE = A_COMPL_SUMMARY.PART_SEQUENCE AND INCIDENT_NOTIFICATION.INCIDENT_NUMBER = MDR_REPORTING.INCIDENT_NUMBER AND INCIDENT_NOTIFICATION.INCIDENT_NUMBER = A_COMPL_SUMMARY.INCIDENT_NUMBER AND ((A_COMPL_SUMMARY.INCIDENT_NUMBER In (?)))
I have a list from another worksheet that changes based off it's query results
Is there a way to have VB change the A_COMPL_SUMMARY.INCIDENT_NUMBER In .... to reflect a list found in the other worksheet?
View 9 Replies
ADVERTISEMENT
Feb 12, 2014
I need to create a macro that can create a dynamic copy/paste loop. So far what I have is horribly inefficient. Each row in colmn A(minus the header) has a unique number in it. For each unique number, I need to paste it based on the number of column headers in row 1(minus column A). So, if there are 20 column headers, I need to copy cell A2 and paste it 19 times in another sheet. Then, I need to move to the next number in column A and do the same thing. Here's what I have:
[Code] .........
You can see that this is not dynamic. If I add another row to my table and rerun the macro, it will not catch it. I've attached a sample file to show you the big picture of what I'm trying to do. The data that I have is in Sheet1, and I'm trying to get it into the format in Sheet3. Rows/columns will be periodically added to the table in Sheet1, so the macro needs to be dynamic to catch that. The data in Sheet3 will always remain, and the macro will add the updated data below the old data in Sheet3.
FC_Macro_Sample.xlsm
View 8 Replies
View Related
Aug 10, 2014
Refer to attached file.
I have below code which successfully create a macro button and assign the macro correctly.
This is only doing for one sheet and i need to modify the code so that it does for all sheets of the workbook.
[Code] ....
Test Macro_Botton.xlsm
View 3 Replies
View Related
Jan 28, 2014
Writing a Marco. I would like to place a macro on the opening page of a workbook and like to a button that executes three functions.
1) I need to hide selected tabs in a workbook
2) I need to copy paste values of a couple select cells in a workbook
3) Lastly, I would like to set up the workbook so that the use can not move beyond the opening tab with out clicking the macro to preform the steps above.
Is this possible? I know 1 and 2 are for sure, what about 3?
View 1 Replies
View Related
Jun 22, 2012
Create a macro that when ran will add 1 to the value of "Feeunits!AE1" In other words if the value is 10 then the macro will change the value to 11.
View 3 Replies
View Related
Oct 5, 2007
to create a macro
the database just like pic in the link
[url]
and the report need to genarate out is like pic in the link
[url]
the part namber and the quantity on hand
if the a part number have the same location but not same lot/serial, then need to sumaries the quantity on hand if location is same.
and the
Location (Quantity On Hand)
20A13(31930),20B04(940).........
need to put in one cell
this is my table
[url]
View 9 Replies
View Related
Oct 8, 2007
is it possible if we select a particular cell and on click on a button a tab will be created automatically with the name of the selected cell and that particular cell get a linked on click of which it will take to the tab that is created.
Example:
A1 has a value jack if i select A1 and i click on a macro button it should create a tab beside my current tab by name 'Jack' and cell A1 should be hyperlink on click of which it wil take me the the 'Jack Tab'.
View 9 Replies
View Related
Feb 9, 2010
I have a workbook open and my A column cells are filled with (example) Mike-1 in the first row Mike-2 in the second row and so on. Now I have another folder on the computer with Word documents that I want to hyperlink to. The corresponding Word file is named mike1. So I want Excel to go through column A and Hyperlink to the corresponding Word file.
View 6 Replies
View Related
Apr 21, 2014
I am trying to create a pivot table using macro. In order to accommodate for changes in data, I used dynamic range.
See below for the step I took:
1) Create dynamic range using offset formula (=OFFSET('CommTest Booking Selections Gre'!$A$2,0,0,COUNTA('CommTest Booking Selections Gre'!$A:$A),21)
2) Record Macro
3) While recording: created pivot table using dynamicrange, added a new column next to the pivot to get additional data (if formula), and formatted.
4) Stop recording and delete sheet 1(where pivot was created) and used the shortcut to re-create the pivot
Once I do step 4, I get an error message: Run-time error '5': Invalid procedure call or argument and highlights the area when I click "debug":
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"DynamicRange", Version:=xlPivotTableVersion14).CreatePivotTable _
TableDestination:="Sheet1!R3C1", TableName:="PivotTable11", DefaultVersion _
:=xlPivotTableVersion14
Please see below for the entire VBA codes:
Also note that, I already saved my file in .xlsm format so macro should work.
Sub Over50KbyPO()
'
' Over50KbyPO Macro
' Total order value >$50K by PO
'
' Keyboard Shortcut: Ctrl+Shift+T
'
Sheets.Add
[Code]...
View 1 Replies
View Related
Apr 24, 2014
I have this following code to create the PPT with a specific template. But in this, the first slide of the PPT are coming blank. How to remove those blank slides?
PHP Code:
Sub CreatePowerPoint()Answer = MsgBox("Are you sure you want to continue?" & vbNewLine &
"Clicking 'YES' will create the DU Dashboard PPT" & vbNewLine & "You may want to set the range & Update VOC graph",
vbYesNoCancel + vbInformation, "Warning: DU Dashboard graph")If Answer = vbYes Then Else Exit Sub
'Add a reference to the Microsoft PowerPoint Library by: '1. Go to Tools in the VBA menu '2. Click on Reference
[Code]...
View 9 Replies
View Related
Aug 18, 2014
I have a workbook which tracks the current status of jobs and then records the changes on a separate worksheet in the workbook. Right now it is a time consuming process to enter the changes in the status log worksheet and then go enter them again in the change history worksheet.
I am wondering if there is a code that will allow the worksheet to automatically fill in an entry when something comes due. In my attached sample workbook on the 'status log' the Job number 372 in the CA # column is set up to be due today. We see in the 'what is due' column that corrective action is due.
I would like excel to automatically make an entry in the change history worksheet whenever a job becomes due. The change history worksheet has a highlighted row showing how the output would look ideally.
I know nothing about code or vba
Sample Workbook.xlsm
View 1 Replies
View Related
Feb 18, 2008
I want to create a Macro that will create a new worksheet when the user so desires using a message box.
The workbook contains 4 tabs, for example, named as follows: (1) template (2) 250 (3) 825 and (4) 975. I want the marco to work as follows:
1- Macro will ask user "please type store number"
2- Macro will then make of copy of "template" and create the new sheet
3- if user types in "860", I want to the macro to name the new sheet "860" and place the new worksheet between sheets 825 and 975.
Also - this may be asking too much but is it also possible to also prevent user from entering non-valid numbers? The valid numbers are 001 - 999. ie; if user enters "1500", return message "invalid entry".
View 14 Replies
View Related
Jul 17, 2008
I currently have a macro that uploads information on a daily basis for hours worked on campaigns per employee. It then converts the data into a pivot table where it uses relative references to copy the total from the bottom and paste them on to another worksheet. I am now trying to use hyperlinks to link the total back to the pivot table. With daily updates though, the data is constantly being pushed down and is located in a new cell each time. How can I get a hyperlink to work for an area thats constantly changing?
View 9 Replies
View Related
Apr 5, 2006
I am using an excel add-in to create a DDE link between a market data provider and my spreadsheet. ( Add-in is called SigTools.xla )
DDE link works fine and target cells are updated dynamically as market data changes so my excel sheet values are changing constantly.
The formula =WinRos|LAST!GOOG will update target cell with most recent market prtice for Google.
Since this formula is not an excel formula I can't reference excel cells with formula - ie =WinRos|LAST!Indirect&A3 or anything like this won't work.
I thought a Macro might work to simulate "typing in correct formula" and I created following Macro which I thought would work but unfortunately it does not.
Sub Macro2()
'
Dim strSymb As String
strSymb = Cells(4, 1).Value
Application.Goto Reference:="TargetCell"
ActiveCell.FormulaR1C1 = "=WinRos|LAST! & strSymb & "
End Sub
The idea was that Macro would behave just as if I typed in =WinRos|LAST! & strSymb & and substituted the symbol name contained in Cells(4, 1) - whatever that happenned to be.
Seems reasonable but I get an error "Application-defined or object-defined error"
Alternatively I could re-type the formula each time but it would be much better to somehow reference a specific symbol in a particular cell via functioning Macro.
View 2 Replies
View Related
Dec 28, 2011
I have the following code:
Code:
Sub AddFormsButton()
Dim sShape As Shape
With Range("J1")
Set sShape = Sheets("Exposure Country").Shapes.AddFormControl _
(Type:=xlButtonControl, Left:=.Left, Top:=.Top, Width:=96, Height:=20)
End With
[Code]...
Which is called within another macro and inserts a button onto sheet Exposure Country, after which the macro it was called from then stops (i.e. End Sub)
What I would like is that when the user clicks on this button it selects another sheet but I'm not sure how to achieve this.
View 5 Replies
View Related
Apr 30, 2013
Is it possible to create a new workbook, add a macro to it, set it to run as an auto open event and then save and close the new workbook?
To explain a little better, I have a macro in a workbook. This workbook is opened by Filemaker which triggers the macro to run. The macro creates a number of different workbooks using information from an online file dump which is then imported into Filemaker.
However when the import is finished, I'd love for all the files that have been created to get deleted again. Now I realise I could just create a second workbook that Filemaker opens once the import is finished that deletes all the files. However I want to keep things as simple as possible for the user, and for them to have as few files as possible so things are less likely to get misplaced in the future. My concern is as they never see the workbook macro firing, they won't realise how important it is, even if I make it very clear.
So what I was thinking is at the end of the first macro, it creates another workbook, with an auto open event macro in it that simply calls a macro from the original workbook, and once created it is saved and closed. When Filemaker is finished with it's import, it could then open the new workbook which calls the macro in the original workbook. I could then have the original workbook macro delete all the added files, and close and delete the other macro enabled workbook it created. Which would leave me with the original workbook only.
View 3 Replies
View Related
May 21, 2014
I would like to set up an index sheet the will contain hyperlink to all the other sheets. Is a new sheet is added or deleted the index sheet must be updated
View 5 Replies
View Related
Jun 9, 2014
I had in my macro toolbox a macro where in column A I listed names for worksheet the macro would then create and name the worksheets from the list in Column. But unfortunately our share drive where I kept the toolbox crashed and all the data was lost.
View 1 Replies
View Related
Jun 11, 2014
I would like to create a macro (with button) that can be used in any workbook. I tried creating a macro in a blank workbook and added a macro button to the Quick Access toolbar. It shows up in any workbook I have open BUT when I run the macro, it also opens up the blank workbook.
View 1 Replies
View Related
Feb 26, 2008
I need to create new worksheet with all the rows which has qty (column A) value of 1 and above by clicking on a submit button....
View 9 Replies
View Related
Sep 30, 2008
I have a workbook that is tracking part-time faculty appointments. Names and appointment details are entered on the first worksheet ("Entry"). I have another worksheet that pulls data from Entry to generate a summary of the salary for each appointment. Right now, this worksheet is called "Template" that needs to be copied and renamed for each appointment entered.
So, Entry could have up to 56 columns of data entered. There are nearly 100 rows of information for each entry (portrait-style for ease of printing). Columns A and B are information and will not have any entries. Column C is the starting point for the entry of appointments. Cell C5 will have the first appointment Name.
What I want is to create a macro that will copy the Template worksheet as many times as there are names entered from C5 and beyond (D5, E5, F5, etc.) When it creates each new worksheet, I want it to rename the new worksheet with the contents of row 5. For example, if "Smith, J." (without the quotes) is entered in C5, I want a copy of the worksheet Template called Smith, J.
The renaming of the sheet is important because I have a cell in Template that pulls the worksheet name, which is then referenced by cells in Template to pull the information pertaining to that appointment.
What I have seen here on Mr.Excel is a macro to rename a worksheet based on a specified cell, and I've seen something that looks like it created new worksheets, but I haven't seen the two put together like I'm looking for. I am also not that adept at the VBA, so I haven't really been able to figure out how to cobble it together myself.
To summarize:
- I have two worksheets: Entry and Template
- Names are entered into cells (C5, D5, E5, F5, etc.) on Entry
- I need to copy Template as many times as Names are entered and rename each new copy with that Name (also, new sheets should be generated at the end (right) of the current list of worksheets)
- The whole process can be activated by a button on Entry
View 9 Replies
View Related
Feb 3, 2009
I would like some help with a macro code. I need to create a number say in cell I24 on sheet 1. this number is a sum of a random iteration and so will be differnet each time.
i want to run 5000 iterations through and record the 5000 different numbers that appear in this cell into a list - say going from D10-D5009 in sheet 2 of the workbook... - then i will perform the relevant statistical analysis on the data...
so essentially i would like the macro to hit the F9 key 5000 times and then record those 5000 results for me on sheet 2...
View 9 Replies
View Related
Feb 17, 2010
I've created what I thought was going to be a simple macro which will create a new workbook, rename it "Applications Calls", then copy a pivot table/report from another workbook and paste it. Here's my rather amateur code which doesn't work.
Sub copyreport()
Workbooks.Add
ActiveWorkbook.Name = "Top Ten Apps Calls.xls"
Windows("Applications Calls Logged North.xlsm").Activate
Sheets("Calls Logged by Customer").Select
Cells.Select
Selection.Copy
Windows("Top Ten Apps Calls").Activate
Cells.Select
ActiveSheet.Paste
Range("A16").Select
ActiveSheet.PivotTables("PivotTable5").PivotSelect "Silo", xlButton, True
ActiveWindow.DisplayGridlines = False
ActiveWorkbook.ShowPivotTableFieldList = False
Range("A16").Select
End Sub
View 9 Replies
View Related
Jan 25, 2013
I have created a macro to use auto filter with the name specified in the vba code, can I specify a range of cell to do Sutofilter.
View 7 Replies
View Related
Sep 20, 2013
I have 2 sheets in one excel file.
I need a macro to check how many rows have value in sheet b and then insert rows accordingly in sheet A between cell B11:B100.
For E.g. if there is value from cell A1 to A150. than I want the macro to add 50 more rows in Sheet A between Cell B11 & B100 and also copy the formula that is there in cell N11 to Z100.
Data in cell A1 to A150 can be between 0 to 999
View 2 Replies
View Related
Feb 6, 2010
Currently where I work we print out registers to keep track of student attendances. This is done by merging an excel document that contains all the details of the names, days, dates , times, student groups and rooms of each lesson (each row contains the details for one lesson) with a word document containing the appropriate list of students in each specific group along with blank mail merge fields that relate to the excel document.
There are often 100 lessons a week meaning it takes an age to merge all the documents to create the registers.
Instead of this method I'd like the tutor to print off their own register by opening the excel document and clicking a button at the end of the appropriate row that contains the details for the lesson they are teaching. This would then take the details from that row and generate the appropriate register on another worksheet. Importantly it would have to list the correct group of students for each lesson - the names of these groups would be listed on other sheets.
Im guessing macros would be the right way to do this, but I have no real knowledge of them so alternatives would be helpful. Can anyone point me in the right direction? I've included a sample of how it would look with just one lesson in the excel doc.
View 8 Replies
View Related
Dec 29, 2012
I want the following macro to be used as an excel addin, how to create addin and feed this macro on that particular addin so that its available each time I open a new workbook.
The macro is : [Code] ...........
View 2 Replies
View Related
May 22, 2014
Is there any way to create a Macro that is any cell in column D has the word Shop it would change the adjacent word in column E from Roof Time to Shop Time?
View 1 Replies
View Related
Jun 3, 2014
Can record the all those actions which we need to do on a regular basis. In my work i have to create the pivot table to a data which gets changed every day but the data sequence remains the same.
I have tried to record the macro for the pivot table but when i tried to run the macro again then the below error message comes.
"run time error 5" "Invalid procedure call or argument" when i click on debug then the below macro program is highlighted in yellow color.
View 1 Replies
View Related
Aug 1, 2009
Can a macro from Excel VBA create a Task in Outlook?
I would like to have Excel create a task populated with a date in a given cell in Excel.
Basically, click a button and a task is creaed in Outlook based on the date in a given cell.
Is this possible?
View 10 Replies
View Related