Amending Existing Code To Add New Column To Macro Output
Jun 4, 2014
Attached is my sample data Sample Data_Combine Sheets.xlsm.
What the code in the attached sheet does is that it combines the data in Sheets Set1 and Set2 into the worksheet named "Combine".
Both input sheets share same columns. Code I use is as below:
VB:
Sub BuildPivotData()
Dim wrsht As Variant
Dim i As Integer
Sheets("Combine").Range("A2:AI500").Clear
wrsht = [{"Set1", "Set2"}]
For i = 1 To UBound(wrsht)
Sheets(wrsht(i)).[a2].CurrentRegion.Offset(1).Copy Sheets("Combine").Range("A65536").End(xlUp)(2)
Next i
End Sub
I want to amend the output in such a way that when the macro is run , in the "Combine" worksheet an additional column is added at the start(col A) with header as "Category".
The category should be nothing but the input Sheet name i.e Set1 or Set2.
Here is an example ... Output Sheet.xlsx.
View 3 Replies
ADVERTISEMENT
Jun 27, 2009
i have this code ( straight forward enough )
HTML Sheets("Receipt of deposit letter IWA").PrintOut Copies:=2
Sheets("glass").PrintOut Copies:=1
Sheets("Ggf").PrintOut Copies:=1
Sheets("Job sheet").PrintOut Copies:=1
Sheets("CHECK").PrintOut Copies:=1
Sheets("Completion sheet").PrintOut Copies:=1
but i would like the line completion sheet to printout copies based on whats in cell h12 of working sheet
so if h12 has a 3 in it it prints out 3 copies
View 13 Replies
View Related
Jun 17, 2008
I have managed to create something similar to what i am working for using an example from Lacher and Gant Charts. i am now stuck as I can enter more than 40 status as it then gives me an error. The following is the code: Can any1 highlight where i need to make any changes to stop the error from occuring:
Option Explicit
Sub CreateTimeChartData()
Dim vTimeData As Variant
Dim i As Integer
Dim sRoom As String
Dim vLastEndTime As Variant
Dim oSeries As Series
' set up
Application. ScreenUpdating = False
Application.DisplayAlerts = False
' create chart data worksheet
With Worksheets("TimeData"). Range("TimeList"). CurrentRegion
.Sort Key1:="Room", Key2:="Start Time", Header:=xlYes
vTimeData = .Value
Worksheets.Add
On Error Resume Next
Worksheets("ChartData").Delete..........................
View 3 Replies
View Related
Dec 23, 2009
I'm verrry new to editing VBA code and I've been trying to figure out how to send a column of data ("Min Data" AB3:AB21 from "Sheet1") to a worksheet ("F4" - Min) and sending another column of data ("Max Data" AC3:AC21 from "Sheet1") to a different worksheet ("F4" - Max) by using only the one button ("Record Data" from "Sheet1"
I've been trying to figure out ways to edit the VBA in "Module 1" to make this work
Can anyone help me out here? If what i'm asking for isn't clear enough, just let me know and i'll try to explain in more detail.
View 6 Replies
View Related
Mar 27, 2009
I am trying to combine the 'Mail Range' from this code http://www.rondebruin.nl/mail/folder2/mail4.htm with the 'Mail to address in A1' from this code http://www.rondebruin.nl/mail/folder2/mail5.htm and can't make it work. Maybe this is the wrong tactic to take but I have very little knowledge about writing my own code. The ideal solution would make a copy of a a specific range of cells from a specific sheet, mail it to a recipiant (could change based on what is entered in the field) and delete the copy. I will try to attach an example next week.
View 4 Replies
View Related
Jul 23, 2014
I have months ( 1 to 12 ). Every month, a set of tasks need to be executed which takes "x" number of hours.
So if I have 1 machine working 3 hour in the month 1, the total time spent is 3 hours. Fairly simple right !
Say on month 2, a set of tasks take 4 hours. total time that my first machine takes is 4 hours. But i want to introduce 3 new machines in this month, which will execute the first month's tasks. So total time spent here is ( 3*3 + 4*1) = 13 On month 3, task time is 6 hours. And I am introducing 2 new machines.
So total time is 2*3 ( time taken for 2 new machines to perform first month's tasks ) + 3 * 4 ( 3 new machines introduced last month will now execute second months task) + 6 * 1 ( time the first machine will spend on month 3 s tasks ) = 24
View 2 Replies
View Related
Jan 22, 2009
On the "If not Isempty" line, I am trying to input a box prompt. Instead of standardizing this macro, I want the user to be able to select a dollar amount to search and place on sheet3. Right now it works fine using 1.29 as the amount. However, I have other stores where this dollar amount is different, so I want the store managers to be able to choose an amount to search, for example 1.39, 2.99 etc...
View 2 Replies
View Related
Nov 13, 2011
adding an second range (J1089:AI1147) to the follwing code.
Code:
Sub Clear_Range()
Application.EnableEvents = False
With Range("H3:AL1058")
[Code]....
View 2 Replies
View Related
Feb 10, 2014
I copied this snippet from the net and it has been working like a charm. I would like to add DateLastModified to it, but I can't get it to work, I'm still kind of new to more complex VBA codes. Here is the code...
Code:
Private Sub CommandButton1_Click()
Dim cell As Range
Dim selcell As Range
Dim Value As String
Dim Folder As Variant
Dim a As Long
ReDim Folders(0)
Set cell = Range("B8")
[Code] .........
View 7 Replies
View Related
Mar 25, 2008
my existing macro, as the run takes to much time to complete. (at least 20min) I've already tried several loops, but no one worked for me. Following situation: There are two excel files, entries in column 73 - 85 will be copied from WorkbookRust to the other workbook if the numer in column 5 is the same. Not every cell within this columns contains data, so the macro should automatically jump to the last entry in each of the above mentioned columns, instead of predefine the range as you see in the code below. After the data is copied to the other workbook, it will be filtered acc. to Sub FilterMain and then copied back to WorkbookRust. As already said, the whole thing works, just to lame.
Sub Allmacros()
Dim WorkbookRust As String
WorkbookRust = ActiveWorkbook.Name
ChDir "C:Documents and Settings vogtMy DocumentsRüstplausch"
Workbooks.Open Filename:= _
"C:Documents and Settings vogtMy DocumentsRüstplauschCH_Revenue_2008.xls"
Sheets("Main_Overview").Select
Windows(WorkbookRust).Activate
Application.run ActiveWorkbook.Name & "!UpdateEntries"
Application.run ActiveWorkbook.Name & "!FilterMain"
'not ask to overwrite existing file
Application.DisplayAlerts = False
Workbooks("CH_Revenue_2008.xls").Save
Workbooks("CH_Revenue_2008.xls").Close
End Sub
Sub UpdateEntries()......................
View 7 Replies
View Related
Nov 19, 2013
I have come across this wonderful piece of code that kind of accomplishes what I am after, to a point. Though I would like the output string to be displayed with a few extra characters.
Code:
Function Concat(rng As Range, Optional sep As String = " , ") As String
Dim rngCell As Range
Dim strResult As String
For Each rngCell In rng
If rngCell.Value "" Then
strResult = strResult & sep & rngCell.Value
End If
[code].....
I want the output to be:
["cell1" , "cell2" , "cell3" , "cell4" , "cell5"]
View 2 Replies
View Related
Dec 27, 2012
I have a spreadsheet with sales which I colour green when they are outstanding and red when they are despatched. I would like to automatically add a 1 in an adjoining column when the cell is green (eg outstanding) or zero when they are despatched so that it totals up the number of outstanding orders.
a b
172.95 (this column would be green)
024.00 (this cell would be red)
124.00 (this cell would be green)
132.25 (this cell would be green)
View 3 Replies
View Related
Jun 20, 2013
I need a code to use existing IE tab to pass different queries on google search.
For example:- If active cell contains "manoj Kumar" then macro will search "manoj Kumar" on google and if i select another cell then code will pass the another google search query on the same active IE window(It will not open new window or new tab).
View 4 Replies
View Related
Jul 11, 2007
I use for another template and it works fine. Only change I would like to make is the column headers starts in Row 4. Col B. Some how this is not working for me.
Sub ITD_REV()
Application.ScreenUpdating = False
With Sheets("Data").Rows("1:1")
Set c = .Find("CONTRACT #", LookIn:=xlValues)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
c.EntireColumn.Copy
Sheets("Test1").Select
Range("B3").Insert shift:=xlRight
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address FirstAddress
End If
End With
End Sub
Again...incase what I said does not make sense: I want to copy certain columns with fixed header names, e.g. "CONTRACT #" into another sheet name "Test1" and paste starting into cell B3. Another column would be "Contract Name" and so on. Also, these col header names may not be in order. In "Data" sheet, col header names starts in row 4.
View 9 Replies
View Related
Aug 29, 2008
I have already got an anwer for this long back from this site. The code was writted by Mr. Krishnakumar
the thread is here :[url]
i need some changes to be made in this code. The existing code creates and updates the details in the sheets automatically from the master data. I just need the sum of Column I in all the sheets after the last row of Column I.
selecting all the sheets and typing the formula in I column is not possible because, the last row in Column I is different in all the sheets.
In sheet 1, the last row of Column I is Row 15, in sheet 2 Row150 is the last row.
I guess something could be done in macros.
follwing is the existing
Sub TestIt()
Dim sWS As Worksheet
Dim Sellers As Range, Seller As Range
Dim lRow As Long, fRow As Integer
Dim CopyRng As Range, ws As Worksheet
View 9 Replies
View Related
Mar 24, 2008
i have this formula below which works but if the criteria is not there it says FALSE because of the B22:C45,2,0) bit i would rather it says something like "no dissertation" is that possible? ...
View 10 Replies
View Related
May 21, 2009
I have two sheets - sheet1 and sheet2. Everytime i run a macro in the sheet1and manually copy the rows from sheet1 {starting (A2:AI2)} and paste as values it in the sheet2 {starting (A2:AI2)}.
Then I ll delete the available datas in the sheet1 and will run a macro for different customer.
Again I need to repeat the same action (manually copy and paste the datas to sheet2) without replacing the existing data in the sheet1.
In simple I require a macro code where it copy the available information in sheet1 and paste it as values in the sheet2 without replacing the existing one.
View 14 Replies
View Related
Feb 3, 2013
How to amend existing code in a workbook that is used by many different users. I am working in Excel 2003. The existing code copies data from certain cells in the active worksheet (which is password protected) into a new worksheet and saves that new worksheet to a temp folder, sends it to a particular email address using outlook and closes it, returning the user to the first workbook. You will see that it also unhides then rehides columns of the first worksheet during this process so that the user never has to see them. Problem here is that none of the users are using outlook anymore and I would prefer that this new spreadsheet that is created just be saved to the users desktop. I have found bits and pieces of what I needed on the web, but I can't seem to put it all together (I usually end up being sent to the debugger just short of having the newly created spreadsheet saved to desktop). Here is the existing code:
Private Sub CommandButton1_Click()
Range("A2:G2").Select
Selection.ClearContents[code]....
Essentially what I need to do is circumvent the whole email bit and save the spreadsheet that is created to the users desktop instead of a temp folder.
View 2 Replies
View Related
May 30, 2013
I would like the following code to be run for all those sheet/s that has a name = "single" (Not case sensitive neither an exact match) of my active workbook.
Code:
Sub UIUIUI()
Dim LR As Long, i As Long
LR = Range("I" & Rows.Count).End(xlUp).Row
For i = 1 To LR
With Range("I" & i)
If .Offset(, -1).Value = 1 Then .Value = .Value & "-"
End With
Next i
End Sub
View 3 Replies
View Related
Oct 21, 2013
I have a code now that in excel, when the button is clicked, will put file into a new email and format the email.
What I have been trying to do, is make it so that if Cell C10 is blank, you get a prompt telling you it must be filled out before you can proceed with the submission.
Here is the code now:
Sub SendTimeCard()
On Error GoTo err_handler
Dim OutApp As Object
Dim OutMail As Object
Dim subject As String
Dim body As String
' Be sure the workbook is saved first
ThisWorkbook.Save
[Code] ........
View 2 Replies
View Related
Jun 6, 2014
I have some existing code which I did not write, nor do I have the expertise to update. The macro code takes multi rows of data for one person and "flips" the output to be one record per person with columns of data.
The source data looks like this sorted by teacher, Term and Period (columns H and I are the new ones added; the code currently looks through column G only)A
Faculty Name
B
Periodc
C
[Code]......
I just want to add column H and I data to the period course listings by term. So instead of "Term: TM#", just have the display indicate Termcode: Tally/SectSize.... such as (example): "TM1: 20/30"
My Code is as follows:
Option Explicit
Dim wsSource As Worksheet
Dim wsTarget As Worksheet
[Code].....
View 1 Replies
View Related
Mar 10, 2009
I am using Excel 2003 and I have two columns of data, one column shows how much work for a particular worktype should be done in an hour and the second column shows what I’m expected to get in over the next month. I have added a third column to show how long it would take to complete the expected work.
What I would like that third column to show the data in hours and minutes rather than a percentage of 100, so on a linked TAB on the main sheet it will show clearly as a time so staff hours can be allocate to a worktype. Is this simple to do. I have attached an example workbook.
View 5 Replies
View Related
Aug 17, 2005
I have craeted a chart in VBA, which sits in the middle of the page . I have attempted to move it to a new location with the following code
ActiveChart.Parent. Name = "MyChart"
ActiveSheet.ChartObjects("MyChart").IncrementLeft -237.75
ActiveSheet.ChartObjects("MyChart").IncrementTop 32.25
ActiveSheet.ChartObjects("MyChart").ScaleHeight 0.96, msoFalse, msoScaleFromTopLeft
ActiveSheet.ChartObjects("MyChart").ScaleWidth 1.17, msoFalse, msoScaleFromTopLeft
which I adapted from a recorded macro, but which fails in execution, error message indicates that the Object does not support the property or Method.
View 9 Replies
View Related
Mar 24, 2014
I have a workbook which contains 8 worksheets. I want to able to run a macro that looks for specific words in column A of each worksheet and hides any rows in between the specified words. The following code works except if a worksheet does not contain the specified words. Is there a better way to accomplish this?
Attached is an example of the spreadsheet. The code below works just fine on the tabs highlighted in green, but halts on the tab highlighted in red. The tab highlighted in yellow is showing you the rows I need to hide.
Example.xlsxā€ˇ
View 5 Replies
View Related
Dec 11, 2012
I am using the following formula to convert m (months) into y/m (years/months)
=IFERROR(QUOTIENT(AQ8,12) & "/" & MOD(AQ8, 12),"")
where in AQ8 I have m (months)
how do I ensure that the formula does not display any decimal points after the m and instead rounds to the nearest month
ie. 100 to show as 8/4 (not as 8/3.5)
note that I have an additional formula working which gives me the 100 (months) in AQ8
IFERROR(AVERAGEIFS('Raw Scores'!AP$2:AP$65,'Raw Scores'!D$2:D$65,"M"),"")
(so I am guessing that this is rounding it first to the value I see in my cell but it may infact be using 99.84 months for further calcs)
I have tried formatting my cells but this does not work
View 2 Replies
View Related
Jan 28, 2014
Error message: Unable to set the Visible property of the Worksheet class
View 1 Replies
View Related
Feb 5, 2014
Basically someone has coded a VBA script to pull a users details from AD when a button is clicked, using the staff id as the search criteria.
I've amended the criteria so it uses Environ$(USERNAME) to find details of the current logged on user, but i am struggling to get the resulting information out of the Sub to be used in other Subs! It currently just fills a cell with the required info.
View 1 Replies
View Related
Aug 8, 2012
I inherited a spreadsheet to manage that is linked to a SharePoint table.
It is trying to populate a date that a certain "Tier" is selected (1, 2, 3, or 4).
It works great if I manually type in the tiers, but does not run on existing data (about 400 records) or lines that are updated and new via the SharePoint list.
How can I have this run on all of the existing lines and anything added or changed in the future from the list?
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("AD2:AD10000")) Is Nothing Then
Application.EnableEvents = False
[Code] ....
View 9 Replies
View Related
Jul 15, 2014
I have a formula in sheet code to get a total of the following columns. The formula in these columns is not working. I'm not getting any error. The code is working fine without a require output.
Attached File : Total.xlsmā€ˇ
View 4 Replies
View Related
May 3, 2007
I know how to do Vlookup and get the value on the +1 column as following
=VLOOKUP(50, D5:E19, 1)
What about I would like it return the value of -1 Column. Can I using some function of Offset with other functions?
View 4 Replies
View Related