VBA Macro Not Inserting Columns Properly
Jul 3, 2008
I have a VBA macro I recorded that won't insert and copy columns into the proper areas. When I run this, It inserts every column all grouped together.
For example: I want to insert a column before column D, and give certain cells formulas. Instead, it inserts it before column C. The whole macro seems to, when ran, insert EVERYTHING before the range of data I am trying to split up.
Here is the
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 6/30/2008 by kmayfield
'
'
Range("C3:F3").Select
ActiveCell.FormulaR1C1 = "Jan-2008"
Range("G3:J3").Select
ActiveCell.FormulaR1C1 = "Feb-2008"
Range("K3:N3").Select
ActiveCell.FormulaR1C1 = "Mar-2008"
Range("O3:R3").Select
ActiveCell.FormulaR1C1 = "Apr-2008"
Range("S3:V3").Select
ActiveCell.FormulaR1C1 = "May-2008"
Range("W3:Z3").Select
View 9 Replies
ADVERTISEMENT
Oct 17, 2012
I have recorded a basic macro that allows me to copy a formulas in cells CF11 to CH11, and it pastes it into cells in columns CJ to CL. Copy of code is below if you need it.
The issue I have is that I need to insert new coumns into the worksheet, and I need to copy the formulas from columns CF to CH, and they will now need to pasted to columns CN to CP. Note that this is a monthly report where we keep the prior months, so each month will need to add new columns. There are 8 tabs in the workbook, and they all use the same macro, just over different rows (columns all line up).
Is there a way that I can get the macro to paste into the correct column without me having to adjust the macro each time?
Copy of code is as follows:
Range("CF11:CH11").Select
Selection.Copy
Range("CJ11").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("CJ20:CL20").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
[code].....
View 5 Replies
View Related
Feb 21, 2013
The code below is supposed to insert a column and rename it. However, when I debug, the code only renames the column, it does split or run the loop. I press debug again, and then code executes as it is intended.
I can't explain why I have to press debug twice for in order for the code to work properly.
Code:
Sub renameColumns()
With Sheets("byPosition")
Columns("E:E").Select
Selection.Insert Shift:=xlToRight
.Range("E1").Value = "Exemption"
.Cells.EntireColumn.AutoFit
[Code] .......
View 2 Replies
View Related
Jan 27, 2014
I have created a macro 'uid' and rename the module to 'profession'. In the list of macro 'alt + f8' the name displays 'profession.uid' which confuse me. I want to display the name 'uid' and not 'profession.uid'. I select the macro by pressing the first letter of it as in this case 'u' and reach that macro and click it to run.
View 4 Replies
View Related
Jun 3, 2014
my macro filling down the data properly. I have a table wit headers set up. My macro selects two cells in the first row, and tries to copy it down into the other rows of the table. Instead what happens, the macro copies down the table headers into the two cells that are selected. Here is my code.
Range("I3").Select
ActiveCell.FormulaR1C1 = "Order Filled"
Range("J3").Select
ActiveCell.FormulaR1C1 = "Order FIlled"
Range("I3:J3").Select
Selection.FillDown
View 3 Replies
View Related
Apr 13, 2014
In the attached sheet, one macro is developed which is not working properly. My req is to convert date from dd-mon-yyyy to yyyy/mm/dd format. (23-jan-2010--> 2010/01/23)
If incomplete date is there, then hyphen should place the gap i.e.
For date like APR-2014------> Output should be 2014/04/--
For date like 1998 -----> Output should be 1998/--/--
The below macro works only for row number 11, 15 and 16.
[Code]....
Attached File : date.xlsm‎
View 5 Replies
View Related
Apr 23, 2012
I have data in 4 columns, A, B, C, D. Each column has 5 rows of data. I want to write a macro to automatically insert 2 columns, after each column in original dataset.
View 8 Replies
View Related
Sep 25, 2012
what i want to do is have an area where i can input data and then i have three options of inputing the data or resetting data that is already in the list of data so i start to create a list of data but i can reset/change values if i wish for example quantity. i would also like to have a way to subtract or add a number from the quantity assigned to a code/name of some form. i know that's quite a bit
View 3 Replies
View Related
Jul 13, 2009
I have been struggling to figure this out for several days now and i don't really know where to go from here.
I have 2 columns and i need to break them up at certain points.
The attached excel file should hopefully be clear enough to show what i mean.
The first tab is how the data starts the second tab is how i want it to look.
To clarify i need to break it after each change in the first column. ie from 1 to 2.
Furthermore, i need to break the "sub groups" the second column up after 15, and 30. I will never have a number larger than 32 in the second column.
I think the excel file will clear up what i mean.
View 13 Replies
View Related
Sep 30, 2009
I have a macro recorded that inserts into column E in the attached report, and then retrieves data from another worksheet in the workbook. In column D I am trying to keep a 6 month average which includes the latest inserted data, however every time I insert a column the relationship with column D is moved out by one. e.g. range E8:J8 becomes F8:K8.
I am also stuck with setting up a macro to import a new model into the report. I have set up a worksheet called new model with the manufacturer, model and fail descriptions, however all macros I have recorded fail when trying to insert the manufacturer and model into mulitple cells.
View 9 Replies
View Related
Feb 7, 2014
I have a very simple inventory spreadsheet that I used to keep track of certain products. The issue is that I often have to insert new columns and when I do, the formulas get convoluted. Is there a trick to making them follow the structure of the formula before?
My formula is =SUM(GT4:GU4) and appears in the Running Total column. When I insert two columns - a white column where an order will be inserted, as well as a running total column. When I perform the insert, the formula for the inserted columns, as well as the set of columns immediately to the right require corrections:
Inserted columns: =SUM(GT4:GW4) [Should be GV4:GW4]
Columns to the right: =SUM(GV4:GY4) [Should be GX4:GY4]
I know how to manipulate the formulas correctly, I would like to keep a clean file for my predecessor.
View 1 Replies
View Related
Jul 21, 2014
I'm building a bookkeeping workbook that is only currently 800kb with TWO cells that have data validation and no cells have conditional formatting. There are a fair few formulae but they are all simply SUM, SUMIF and CONCATENATE.
View 1 Replies
View Related
Jan 7, 2010
I am instantiating Excel 2003 from vb.net and populating the spreadsheet from SQL. The workbook itself will be maintained even when the .Net program is inactive (so that the column headers are established and saved.) Is it possible to prevent the users from inserting columns within a certain range?
View 2 Replies
View Related
Jan 10, 2012
I have a spreadsheet that I can modify. It currently has a three product column but I need to insert 2 or 3 more columns to make 5 plus the total at the end. It also have a summary sheet. I insert the 2 columns and somehow got the formulas flowing. However when I hit the summary page its not showing results for those two new columns in the total. I am lost. I wish I could post the sheet. Its a multiple product break-even analysis exercise.
View 1 Replies
View Related
Apr 29, 2009
lets say i have 200 used columns. if i delete 150 of them and then (without saving the file) try to add 100 more i get an excel has reached its limit error. theoretically 200-150+100 = 150 columns, which should be well within the 258 column limit. but excel still gives me the error )its like its calculating 200+100=300 > 258). HOWEVER, if i save the file after deleting, i dont get any errors at all. is this a "feature" of excel and if so is there anyway of circumventing it? because i dont want to save the file prior to adding the columns (i do the whole thing in vba). actually i dont want to save the file at all unless the user click on the save button or choose save/save as from the menu.
View 9 Replies
View Related
Nov 20, 2013
For some reason I don't seem to be able to insert any columns/rows/cells in to my excel spreadsheet. This is a problem in both basis sheets and more advanced ones.
View 1 Replies
View Related
Jan 19, 2012
the following issue:
I have a spreadsheet of questionnaire responses which range from 1-7
For example:
Respondent Q1
1 4
2 3
3 7
4 6
So each row is a new respondent and each column is their response from the scale.
What I need to do is code the responses into a different form. I need them to be represented as follows:
Respondent Answer1 Answer2 Answer3 Answer4 Answer 5 Answer 6 Answer 7
1 0 0 0 1 0 0 0
2 0 0 1 0 0 0 0
So that each number then represents the place on the scale from which it was chosen.
I tried recording a macro but I think this requires something a lot more complex.
View 3 Replies
View Related
Jul 7, 2007
firstly i am cross-posting this topic so here is the URL to the same thread in a different forum.
[url]
whats up everybody? i have to use two excel worksheets that someone else already created to make CSV (comma seperated value) files. these CSV files are to be dumped into a database. the problem is that the table has more fields than the spreadsheet does (the spreadsheet has 3 fields - network, mask, size - and the table has 10 fields). i can insert one entire column before (to the left of) network (for the ID field in the table) without a problem, but when i try to insert entire blank columns after size (to the right of the pre-existing columns) it only makes columns for the first 14 rows. i know this because when i save it as a CSV file there are only 6 extra commas for the first 14 rows. is there a way to insert an entire blank column for the entire spreadsheet (as in all the way to the bottom)? i dont want to have to manually type in all those commas. i am using excel 2002.
View 9 Replies
View Related
Nov 12, 2013
I have a sheet with 2 tabs. On the first tab is my data and the 2nd tab is the formula.
This is my formula;
=IF(ISERROR(VLOOKUP(A3,Data!$A:$AD,23,0)),"",(VLOOKUP(A3,Data!$A:$AD,23,0)))
When I insert a new column at 'A' the formula changes (as below)
=IF(ISERROR(VLOOKUP(A3,Data!$B:$AE,23,0)),"",(VLOOKUP(A3,Data!$B:$AE,23,0)))
How do i stop the reference changing from 'Data!$A:$AD' to 'Data!$B:$AE' when inserting the column?
View 2 Replies
View Related
Mar 16, 2009
I'm wanting to add a button on the last row of a worksheet to "add rows" above the buttion (entire row). I have some cells (6 total) that have a formula that needs to carry over to the newly created rows. Some cells remain blank but some cells need to have the formulas fill down to the new rows (i.e.: =sum(a2+1), =sum(a3+1)...
Is it possible to give option of choosing how many rows someone wants to insert?
Help in creating the button, option to choose # of rows and the macro to insert those rows.
View 12 Replies
View Related
Mar 5, 2012
Is it possible to insert for example Private sub Workbook_open() into This workbook by executing macro?
View 8 Replies
View Related
Dec 22, 2006
simple little procedure to insert columns on two sheets and call each by the same name. Macro runs off a command button and inserts a column at E:E and gives the user an input box with which to name the inserted columns.
Code: ...
View 9 Replies
View Related
Aug 8, 2006
I need to insert a new row, in a spreadsheet, after every ninth row that now exists. How is this easiest done?
View 3 Replies
View Related
Feb 14, 2007
How can i make a macro that inserts todays date, tomorrows date, the next day and the day after that??
View 2 Replies
View Related
Feb 23, 2009
see the attachment. You will see that I have recorded two macros:
1) To insert a new row for new people.
2) To insert a row for new animals.
With regards to 1), I would like to create a macro that copies the contents of the row with the penultimate name in the people section, and for a new row to be inserted beneath the copied cell. Similarly, with regards to 2) I would like to create a macro that copies the contents of the row with the penultimate name in the animal section, and for a new row to be inserted beneath the copied cell.
The issue that I have is that the macros do not copy the penultimate cell in each section, but copy a particular row, say row 11 each time I want to insert a new animal. So if I had inserted numerous new rows for the people section, and subsequently wanted to insert a new row for the animal section, I press “crtl+sht+a” which copies the contents of row 11 and which is not the contents of the penultimate row for the animal section.
View 2 Replies
View Related
Feb 24, 2009
I have two sections to this spreadsheet: 1) the entity section; 2) the order section.
I have created a macro to insert rows in both these sections. The macro appears to work fine for the first section but not for the second section. The problem I cannot solve is in respect of cells D9:D10. The macro is as follows:
View 6 Replies
View Related
Mar 18, 2009
I'm trying to write a macro that inserts multiple rows by giving user a MsgBox to enter the # of desired rows. Meanwhile, I need to make sure that the formulas in certain cells are filled down (not just copied from cell directly above). I put something together but it's only adding a single row. Attached is my sample workbook.
View 2 Replies
View Related
Sep 30, 2009
I am trying to create a macro that will create a comma and space between every 5th character within a cell. that would be preference #1. What I decided to go with for now, instead, is to try (using the macro recorder) text to columns, fixed width, and do this after every 5th character, and selecting each cell to be formatted as text.
What I am having difficulties with is trying to tell the macro which cells to touch and which ones not to. I do not want the macro to do text to columns and fixed width on simple text. I only want it to do the macro when it is a string of numbers that, during transfer from PDF to excel, have been concatenated into one cell. I also want the macro to do this for infinite number of rows. I have excel 2007.
I am attaching a small excel file with examples of data I am working with. I have saved this excel file as a 97-2003 version for those who do not have 2007. As I stated, if anybody can help me figure out how to do a simple insert comma space every 5th character where information has been concatenated, that would be preference. Also, I am not trying to change anything within column A. Only column B. On the sample file please note B3 - B6. Rows 5 & 6 are fine as they are. Other problem rows include B11 - B13
View 2 Replies
View Related
Oct 19, 2009
I would like to create a macro that will automatically insert a page break based on the contents of the cell.
A1:A4 = has value
A5 = BLANK
A6:A14 = has value
A15 = BLANK
and so on....
I would like to put a page break in A5 and A15....and for those cells that are blanks.
View 11 Replies
View Related
Mar 21, 2008
Just a quick on i hope. Im trying to create a macro that adds a worksheet/tab and Rename it to the month after the tab already showing.
e.g
if i already have two tabs one dated january and the other named february i require the macro to say march then the next run would be april if you get my drift.
View 6 Replies
View Related