Insert Line & Update Macro
I have created this macro below however if on the worksheet I insert a line or lines the macro range G25:G107 does not change - it remains static.
How can I get an insert of a line to increase the macro range by the number of inserted lines. For example if I insert 2 lines then the macro range s/b now G25:G109.
View Complete Thread with Replies
Related Forum Messages:
Multiple Line Insert With Macro
I have two sheets that i am working with sheet1 and sheet2.
I need a macro that will insert multiple rows in row 8 of sheet 1.
I also need it to copy the formula from row 8 sheet1 to every new row inserted.
the number of rows inserted will depend on colum A from sheet2.
*column A contains numbers, and the amount of numbers will vary. The data starts in A11 and continues down.
So for example. if sheet 2 column A11 and A12 and A13 are the only cells that contain numbers, then the macro will add 3 lines starting in row 8 of sheet1 and it will also copy the formulas from that row to every new row inserted.
Macro To Insert A Line And Duplicate Data
Worksheet excel with multiple lines and colums. I need a macro to automatically insert a new Line where the cursor is located, and duplicate data from previous cells: let say cursor is located L10, macro will insert L11, and duplicate L10 -C1 data to L11 -C1. I have a macro that does this function, but the Line insertion is always at the same line.May be the macro should "read" first the cursor position, Lx and then move down +1 line prior to duplicate the data.
Insert A Line Of Text
Simple question: Can an Excel Macro insert a line of boilerplate text under the last thing copied to a worksheet? I want to paste something into a worksheet, and add a message under it, and a blank line.
Line Insert After A Change In Column H (VBA)
I currently have a macro that does several thing, i want to add another task.
I need a row inserted everytime there is a change in column H from "0" to "F" only. The infromation will always start in row 8 but the last row is not always the same, it will be different every time.
ABCDEFGHI112345678223456783#N/A#N/A#N/A#N/A#N/A#N/A#N/A45B=Bi-WeeklyID type 2ID Type 308 GAPamount due6HCCompanyS= Semi-MonthlyCO#NAMEFORMER (F) or Current (0)78546WalreBbr55a234amy01009524WalreSn32m56daniel05001041WalreS589653jode0100011945WalreBef343456caryF2001212WalreSg5365M5665mikeF40013Grand Total2,200.00
VBA - Insert New Line At Top Of Predefined Table
I currently have a 200 row table spanning 10 columns. There is one numeric column and the rest are free text. The table charts the different contents on one of the shared drives here at work. The drive is frequently in use with things being added and removed from it.
I have an excel table already which can sort the contents in order of size (numeric row) or name of the folder (the first text column). I have two buttons at the top.
The first inserts a row, which I did by recording a macro and then copying the code into the button.
The second I would like to do the following: When a user selects a cell in a row, the button, then clicked, deletes the entire row. Not just the data in it, but excises the row itself and stitches the surrounding materials together. The code to delete a row I could obtain easily, but I can't work out to say "find the selected cell, and take out the row it belongs to".
Insert Line And Copy 1 Cell From Above
I have a large spreadsheet of demographic data. In column A there is a name, in column B there is Address1 and in column C there is Address2. First I need to insert a new line under each line of data. Then I need the Address2 data (column C) of each line to be copied/pasted to that new inserted line, but in the Address1 column (column B).
Insert 2 Lines Under Line 6 In The Active Sheet
I have to do a large amount of routine work with a large number of sheets. I have tried to record some macros to do the job.
First of all I would like to insert 2 lines under line 6 in the active sheet.
I then need to drag the formulas found in line 6 down over the two new lines.
Thirdly i would like to change the text string "xxx" in the formulas found in line 7 to "yyy"
Insert Line Feed At Intervals In A Phrase
Each cell in Range("A1:A2000") contains a remark, each phrase or remark is
Between 5 & 70 characters all written without line feeds (carriage return,i mean Alt Enter) Just spaces between words. What I would like to do in every cell is to force a line feed (Alt Enter) every 10 characters, and if the 10th character happens to be in the middle of a word I want the line feed to be inserted at the end of this word. Note that the phrases are not necessarily multiples of 10.
Insert Row/column - Update Macros
I have several macros running on my workbook, referring to different cells. When I add/remove a row/column in my workbook, I need to manually update all cell references in the Excel macros so that they point at the correct cells after the new rows/columns have been inserted.
Update Data By Ado - Change/delete Data And Then Run Macro For Update Data In Source Spreadsheet
I have one source spreadsheet, where are columns NAME, DATE. I read these data by ADO to other spreadsheet, where I can change/delete data and then run macro for update data in source spreadsheet. The problem: In source spreadsheet is column "NAME" and column "DATE", with values e.g. "Joseph"; 1.1.1980. I read this data to other spreadsheet, then I delete in it value 1.1.1980. When I run macro Update, it messages error.
.Fields.Item(1).value = activecell 'activecell value = "Joseph"
If Not isempty(activecell.offset(0,1)) Then
.Fields.Item(2).value = activecell.offset(0,1).value
.Fields.Item(2).value = "" 'I tried Empty and 0 too but when I read data again then, it displays 0.1.1900, nothing works
It seems that in source spreadsheet has data in column "Date" format Date and when I try to update data in format String ("") in source spreadsheet by Update macro, it messages error. When I used
.Fields.Item(2).Value = Empty
.Fields.Item(2).Value = 0
after rereading data it displays 0.1.1900 What I want to get is that if the cell with date (in other spreadsheet) is empty, the cell in column Date in source spreadsheet after updating will be blank (contains no values).
Worksheet Change Macro Takes Too Much Time When Run With Update List Macro
I have a worksheet in which I have a worksheet_change macro. This worksheet_change macro makes sure that a few cells will keep their colors, even if the user copies and pastes a new value to that cell. This worksheet_change macro runs each time there is a change on the worksheet. Now my problem is that on the same sheet I have an update list macro which updates around 20.000 rows and two columns (which is alltogether around 40.000 values) and it takes a while to run. So.. it takes a loooooooooot of time (too much) when these two macros both run.
My question is that can I somehow disable the worksheet_change macro while the update list macro runs. I mean something like when I start the update list macro to disable worksheet_change macro and when the update list macro finishes, then reenable worksheet_change macro?
Run The Macro For Each Line In Column
I got to the point where the macro is doing (more or less) what I want.
I now need to run the macro for each line in column C.
Basically my macro is creating 9 lines in column E getting as input C1 only (for the time being).
How do I say to my Macro, please run in E, but the first time you run get as
input value C1, the second time C2 and so on until I've got values in C?
I've looked into the loop documentation (for and foreach) and overall it makes sense, but how to refer each time to the next line in C?
Macro In Csv File Only Looks At First Line
I've download the CSV files from my bank. Somehow I thought they'd import painlessly. I dunno what's happened, these files are bloody ridiculous to look at.
Somehow I've ended up w/ Date, then Amount in the cell under it, then a description of what I bought in the cell below, and then something to the cell to the right of it (a further description sometimes, at other times nothing).
I have about 1500 lines of this so doing this automatically is not in question. I want to figure out how to run a macro to organize this. The logic is fairly simple. Where-ever the cursor is, copy the stuff in there over 2 lines, go back to original starting point, copy next cell, paste it next to where i previous pasted, goto third line, copy, paste next to second place i pasted, and then goto next set of data/dates. So I did that once figuring it could keep repeating the cycle. NOOOO that didnt happen. I did this for one set and then just stopped. Everytime I run the macro it deals w/ the same data. For example I created the macro to start of w/ cells A2, A3, and A4, then goto A6 and stop. I figured once there I could run the macro again, and it would do the same stuff for A4, A5, and A6 that it did for the previous one. Nope, it went back to A1-3.
Of course if someone can give a better idea of how to work w/ CSV in the first place that would also help. It just never made the colums in the right place. I got to choose the variables that would decide when a new column starts but I was never really getting the result I wanted. If this macro works though I wont need to work w/ that anymore.
Here's a sample though of how my CSV looks at the moment. These are three entries. The first one's description takes up one cell, the next 2 have 2 cells each.
MMISCELLANEOUS PAYMENTS Good Life
MPOS MERCHANDISE AMC MISSISSAUGA
Read A Date Rather Than A Line VBA Macro
I have the following code which reads line 54 (row 54) in a spreadsheet and calculates the following using data in subsequent columns. Sometimes the data I need isn't always in row 54, I would rather have the macro read the data in Column A[AB] that is on line 54...sometimes on 53.
The date is Sep-09. How can I make it read this rather than AB54. I think I just need changes @ the top (ie Dim rng as Range, Set rng = [AB54]).
Dim rng As Range
Set rng = [AB54]
rng.FormulaR1C1 = "=RC[-12]+R[-1]C[-12]+R[-2]C[-12]"
With rng.Offset(0, 2)
.FormulaR1C1 = "=((RC[-28]+R[-1]C[-28]+R[-2]C[-28])*4)/((RC[-25]+R[-1]C[-25]+R[-2]C[-25])/3)"
.NumberFormat = "0.0"
With rng.Offset(0, 3)
.FormulaR1C1 = _
.Style = "Percent"
.NumberFormat = "0.0%"
rng.Offset(0, 4).FormulaR1C1 = "=RC[-8]"
With rng.Offset(0, 5)
.FormulaR1C1 = "=(((RC[-17]-RC[-31])+(R[-1]C[-17]-R[-1]C[-31])+(R[-2]C[-17]-R[-2]C[-31]))*4)/((RC[-28]+R[-1]C[-28]+R[-2]C[-28])/3)"
.Style = "Percent"
Macro To Enter Information On A New Line
I am creating a macro that will take some information from 3 cells that the user will input, place it into 3 different cells, clear the original 3 cells and then I would like the macro to, when next activated input the new information from the 3 cells below the information that was already in the table.
Date (D3), Description (E3, F3, G3 Merged cell) and Reference (H3)
I would then like those 3 cells to be put into A9:E9 then clear the original cells. That is not the part that I have the problem well, the following however, is.
After I enter new information into the input cells, and press the macro button, I would like the information to be placed into A10:E10 and from then on, the information goes down by 1 row after each macro.
Macro To Set Border Line Styles
I have a range of data (not a named range, just a selection) and I typically want:
- the top 2 rows to have a heavy border on the left, top and right sides with a light line on the bottom.
- On the bottom line, I need a heavy line on the left, bottom and right sides.
- The body in between needs to have heavy lines on the left and right sides with dots for all in between.
The top 2 lines show titles, the bottom line is for totals and the body in between shows the data.
I've made 3 separate macros that do each part but I'm hoping that they can be integrated into one.
Macro Button To Create New Line?
I have 2 tabs on my spreadsheet. The first has some text at the top in cells A1 and A2, and that's it. The second tab I need a script for. Basically, I need some sort of macro button and a text box. I want people to be able to type some text in a cell or box on the 2nd tab, hit a button, and the text that has just been typed will be copied and pasted in to the next available cell down on the first tab.
For example, say the 1st tab had 'title' written in cell A1, and 'hello' written in cell A2. If I were to go to the 2nd tab, type 'bonjour' in to a cell or text box, and hit a button, the text 'bonjour' would be copied, the script would read the 1st tab and see that cells A1 and A2 already had text in them, and so paste 'bonjour' in to cell A3.
Line Numbers In VBA Macro Code
If I number my lines of code and an error occurs, the use of Erl in the VBA will then return the exact VBA line number that the error occurred on. Is it possible to automatically capture or record that same effect when the macro process leaves its current sub and goes to another?
Reason: I'm trying to create a Call Stack that can be reported through an Error Handler that will include the exact location and process that the error occurred to better troubleshoot and understand where and why the error occurred.
The best I can come up with so far is manually putting in bookmarks along way so I know how far along the macro went before the error. From all of my searching I believe retrieving the Excel Call Stack is not possible and so one must be manually created.
Enclosed is an example of what I have so far. It goes through several macros and logs the Call Stack. Itís a work in progress so it is a little sloppy looking but it is functional. If a Sub finishes it is then taken out of the Call stack.
Several "BookMarks" are placed to give an idea of how far along the Macro has gone within that Sub. The Code for the Erl example is:
Dim dblNum As Double
10 On Error Goto PROC_ERR
' Errors if table doesn't exist
20 Select Case Rnd()
Case Is < 0.2
30 dblNum = 5 / 0
40 Case Is < 0.4
50 dblNum = 5 / 0
60 Case Is < 0.6
70 dblNum = 5 / 0
80 Case Is < 0.8
90 dblNum = 5 / 0
100 Case Else
110 Exit Sub
120 MsgBox "Error Line: " & Erl & vbCrLf & vbCrLf & _
"Error: (" & Err.Number & ") " & Err.Description, vbCritical
Macro For Creating Line-plots 37
I am trying to make a line plot for traffic data. I want to make 37 different line plots with two series (count 1, count 2) and 72 values and the name of the trafficlight. I attached a text file with data for one of the 37 trafficlights. In my datafile, below the first 72 values the values for the next plot are written. I can make this tables by hand, but I prefer a macro because I want to repeat the exercise for different datafiles.
Macro: Export To Csv Without Header Line
I will admit I am a neophyte when it comes to VBA - I am JUST opening the book (never had to program before). I am trying to figure out how to create a VBA macro that will, with the click of the button, save the data in my worksheet (minus the header line) into a CSV file.
I can export the data I have into a CSV file the normal way, but I DONT want the header line included. And instead of manually removing it each time, Id like to just be able to export it, then send it to the DBA for integration.
Macro Stops At 1st Line Of Userform Code
I have built a small userform with 3 fields. The macro ran OK first few times. Now, when user enters data in the form and clicks OK nothing happens. I found that repeated clicking on OK or Cancel button on form had no effect. I then observed that VBA editor was open and the yellow cursor was displayed on the first code line under cmdOK_click procedure. The code line was also highlighted in yellow. There are no errors to debug and no break points etc. When I clicked the Run (or Continue) icon from the VBA toolbar, the macro completed OK. Question: Why is the macro pausing on the first line and how can I make it run without pausing for no apparent reason.
Report A List Line By Line Based On Name Criteria
Currently I am using Excel 2000. I did a search and couldn't seem to find the answer I was looking for. Hopefully someone can help. It would be greatly appreciated since I have been trying to figure out how to do this for days.
I am trying to create a worksheet that will pull info from a row on one sheet to another sheet based on the name; then continue to list the info on each line afterward until there is no more of the that particular criteria. See below (this is just an example to simplify the data but would need the same process):
This would be the data on sheet 1:
Name Bonus Commision
Tom $45 $50
Mary $25 $75
Mary $30 $80
Tom $60 $50
Tom $90 $25
What I would like to do is have 2 more sheets. One would be Tom's sheet and the other would be Mary's sheet and it would look like this:
Tom $45 $50
Tom $60 $50
Tom $90 $25
Mary $25 $75
Mary $30 $80
I am not completely familiar with all of the functions in Excel and compared to you guys I am a complete novice.
Is this possible to do in Excel without using a macro?
Compile Error: Sub Or Function Not Defined - 3-line Macro
I'm trying to use MATCH to identify the Column number that contains "DL_Error", then I'll use this Column # to select a cell (found Column # & "34"), but I get the error shown in the title of this post.
Here's my current
' Macro recorded 6/18/2009 by me
Range(Match("DL_ERROR", "A31:CW31", 0) & "34").Select
Macro To Update Graphs
I have multiple graphs that read from rows varying in length from 2 to 60 columns long, depending on user input. I need help in creating a macro that readjusts the graphs to read from smaller/larger data set.
I created one that said: If user input = 1, then set graph to (A1:A1), If user input = 2, then (A1:B1), but this is really inefficient. Is there a better way?
Macro Won't Update Pivots
I have a macro that is supposed to update 3 pivot tables with the change to just the first one but it doesn't work. Can anyone help?
Here is my code but nothing happens when I change the first pt (C & S). It doesn't update the other 3 tables.
Private Sub Worksheet_Calculate()
Dim PF1 As PivotField
Dim PF2 As PivotField
Dim PF3 As PivotField
Dim PF4 As PivotField
Dim x As String
Application.EnableEvents = False
Application.ScreenUpdating = False
Set PF1 = ActiveSheet.PivotTables("PivotTable4").PageFields("State")
Set PF2 = ActiveSheet.PivotTables("PivotTable3").PageFields("State")
Set PF3 = ActiveSheet.PivotTables("PivotTable2").PageFields("State")
Set PF4 = ActiveSheet.PivotTables("PivotTable1").PageFields("State")
x = PF1.CurrentPage
PF2.CurrentPage = x
PF3.CurrentPage = x
PF4.CurrentPage = x
Application.ScreenUpdating = True
Application.EnableEvents = True
Pivot Table 4 = C & S this is one I want to make the change to
Pivot Table 3 = Sales Pivot
Pivot Table 2 = 2005 Pivot
Pivot Table 1 = SMG Pivot
Update Cell Only Via Macro
away to have a cells formula only up date via a Macro
A1+B1 = C1
the formula is only done through a Macro so that if it is disabled C1 would be empty?
I guess the trick is how does the macro update when a value is entered in A1 or B1?
Macro- Update Automatically
I have three columns as below,
Column A current Amount
Column B Increse %
Column C Revise Amount
If I put revise amount in column c, than Column B update automatically or if I put % in column B than column C update automatically, update must be live
Update Of Worksheet Using Macro
I need to be able to open a workbook named "Cost Price List" and press an update button which will open Another workbook called "Numerical Pricelist" that will then look up the part number of the item and change the corresponding description only, using the "Numerical Pricelist as the correct master document. There are approx 5000 part Numbers but i have cut a small sample section.
Auto Update Macro
I have a spreadsheet of 30 or so tabs, all of identical layout, with columns B to AS used. Each day I have to drag a row down to collect data from various other spreadsheets, on each of the 30 tabs (different data in each tab, but same format), i.e. today I dragged down B216:AS216 down to B217:AS217 for all 30 tabs. I could record a Macro on the first tab and then play it for the remaining 29, but I have to record the Macro each day so it drags down the next row down.
I am after a Macro that will drag down the columns to the current date (which is in column A and is already entered down to the end of the year) on all tabs, so if I left it for 5 days etc, and then ran the Macro, it will drag down 5 rows. But if I had to run it 5 times that wouldn't matter. A button on the first sheet would be brilliant too, meaning I could open it up, click the button, and then all 30 tabs would drag down to todays date.
Macro To Update List
I ran into a dead with this simple but overlycomplicated task in Excel. How can I write a macro to update one workbook from many workbooks? My case. I have workbook A with 2 sheet tabs, sheet1 contains 6 columns: one for date, one for 0-20%, 21-40% ... 81-100%. Each of the rows underneath the heading contains a single data value ( total) from each of the 5 sheet tabs from the workbook being created each week of the month. Sheet2 build the chart reflecting the data gathered on sheet1.
I need a macro that will update workbook A sheet 1 or add the new data generated that particular week down the columns for each of the columns stated? How can I achieve this?
Display Current Code Line Number While Macro Running
Is it possible to display both the current code line number and the total line count of a macro while it's running?
I was thinking it would be handy for a progress indicator if the ProgressBar max value could be set to the LineCount total of the procedure and each line of code would increment the progressbar as the macro ran.
Put All Values Of A Specifice Line In That Matrix In A Line
I'm working with matrix in vba and i'm trying to put all values of a specific line in that matrix in a line in excel. For example:
and i want Range("B1:B2") = 3 | 4 (the second line of that matrix).
Is there any way of doing this without perfoming a loop?
[something like Range("B1:B2").value = 'range'(matrix(0,0) , matrix(0,1)) ]
Scheduled Time Update Macro
I have the following macro:
WaitHours = 0
WaitMin = 15
WaitSec = 0
NextTime = Now + TimeSerial(WaitHours, WaitMin, WaitSec)
Application.OnTime EarliestTime:=NextTime, Procedure:=LinkUpdates()
Sheets("PRICING SHEET").UpdateLink Name:="P:CommonPRICINGCOMPILATION.xls", Type:=
The code does not work at all, just the skeleton to have an idea. I also need help recreating an entirely new macro which preferably works well!
The idea is that everyday at 8:00AM this macro starts automatically updating the links every 15 mins (SHOULD NOT MATTER IF THE SHEET IS OPEN OR NOT). But here is the catch.
This code should be the code for a checkbox. So when the box is checked, or TRUE, the macro should run normally updating every 15 mins. But when the box is unchecked, the macro should stop (no update occurring).
I want this macro because this sheet is linked to several other sheets and it needs constant updating. However, if I need to make a change in the main sheet, no updates should be happening.
DB Query Refresh/Update Macro
I am trying to write a creative procedure that on workbook open will check the name of the worksheet if it includes the day's date in sheetname & if it doesn't rename the sheet & delete current region from A1, else exit the sub.
Then runs a query on an Access DB to place in the above worksheet.
I need this due to novice XL & DB (8)users.
This is what I have at the moment on a test DB courtesy of J Walkenbach's sample files .....
Update Code On A UserForm Via Macro
I have a time sheet which is used by around 15 people. Part of the timesheet is a userform which adds a new sheet and names it with the seleted month and year. I have made a few changes to my timesheet which I wish to update on other peoples sheets. I am going to send out a speadsheet with a macro that people can run and it will automatically make the changes to their timesheet. I have done all the work for updating the various formats and formuals but I have hit a bit of a brick wall when trying to change the code on a user form via a macro.
It would be great if I could either overwrite all of it or add a some lines of code from a specific line number.
Having To Run Macro Twice To Update Worksheet Fully
I'm no expert with my vba, record a few macros and make alterations to existing code but this is driving me crazy.
I have a simple script which I would like to update all DB links and all Pivot Table information, which my code does but i'm currently having to run it twice before it shows the correct results.
Update Links Only Via Macro Code
I have a 15 excel files which are part of the forecast system. There is another file MASTER which is the host file for the macro. Every months multiple users are asked to update their forecast in the 15 excel files .As these files also display actuals, so they are linked to bunch of other files. The links to the files should not be updated unless I run my macro from MASTER to do the series of tasks.
Everytime these users open the files , they are asked to update links.
Is there a way for me to stop this warning and still able to update the links only when i run my macro from the Master.
Macro Data Dump Of The Date When I Hit 'update'
I have a model which I have created a macro for that will do a data dump of the date when I hit 'update' (on BBG Raw Data Tab) to Column A in the 'Data for Pivot' Tab.
This works fine and all of the data comes over, except the last two data points in BBG Raw data (Cell A5055 and A5056) do not come across into the 'Data for Pivot' Tab (these should be going into Cell A5054 and A5055 of the 'Data for Pivot' tab).
Event Macro; Update A Cell When Change
I have not used an event macro before and am trying to one update a cell when changing a cell. I am basically copying a number to another cell that is an input for a calculation and then returning the calculated value back. How do I reference r69 in the code to start the event macro?