inserting more than one column

What would the VBA code be to insert 6 columns to the left of Col A?  I 
recorded a macro but I know there has to be a quick line of code that will do 
the same things rather than 10 lines of code from the macro recorder.  Thank 
you. 
0
Utf
1/7/2010 4:38:02 PM
excel.programming 6508 articles. 2 followers. Follow

2 Replies
806 Views

Similar Articles

[PageSpeed] 33

Hi

Columns("A:F").Insert Shift:=xlToRight

-- 
Regards
Roger Govier

"SITCFanTN" <SITCFanTN@discussions.microsoft.com> wrote in message 
news:BD9FA6CB-C861-4BCB-93C9-E98232636594@microsoft.com...
> What would the VBA code be to insert 6 columns to the left of Col A?  I
> recorded a macro but I know there has to be a quick line of code that will 
> do
> the same things rather than 10 lines of code from the macro recorder. 
> Thank
> you.
>
> __________ Information from ESET Smart Security, version of virus 
> signature database 4751 (20100107) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
> 

__________ Information from ESET Smart Security, version of virus signature database 4751 (20100107) __________

The message was checked by ESET Smart Security.

http://www.eset.com



0
Roger
1/7/2010 4:52:34 PM
The generalize form of Roger's statement would be this...

NumberOfCols = 6
Columns("A").Resize(,NumberOfCols).Insert Shift:=xlToRight

where you can set a variable number of columns to insert, as needed. Make 
sure you note the comma in front of the variable named NumberOfCols inside 
the Resize property call.

-- 
Rick (MVP - Excel)


"Roger Govier" <roger@technology4unospamdotcodotuk> wrote in message 
news:D18AB55B-1EAC-4F18-80D1-B7E82FC8646D@microsoft.com...
> Hi
>
> Columns("A:F").Insert Shift:=xlToRight
>
> -- 
> Regards
> Roger Govier
>
> "SITCFanTN" <SITCFanTN@discussions.microsoft.com> wrote in message 
> news:BD9FA6CB-C861-4BCB-93C9-E98232636594@microsoft.com...
>> What would the VBA code be to insert 6 columns to the left of Col A?  I
>> recorded a macro but I know there has to be a quick line of code that 
>> will do
>> the same things rather than 10 lines of code from the macro recorder. 
>> Thank
>> you.
>>
>> __________ Information from ESET Smart Security, version of virus 
>> signature database 4751 (20100107) __________
>>
>> The message was checked by ESET Smart Security.
>>
>> http://www.eset.com
>>
>>
>>
>
> __________ Information from ESET Smart Security, version of virus 
> signature database 4751 (20100107) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
> 

0
Rick
1/7/2010 6:10:52 PM
Reply:

Similar Artilces:

Linking a Column List to a Row List #2
Thanks for the help, it worked perfectly -- Mo ----------------------------------------------------------------------- Moe's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1250 View this thread: http://www.excelforum.com/showthread.php?threadid=27428 ...

How do I insert Roman Numerals?
New to Word 2007 would someone please explain to me how to insert Roman Numerlas in my document? "ckj" <ckj@discussions.microsoft.com> wrote in message news:6CF0C580-BA6E-463D-B4FD-E6A6FDD9E814@microsoft.com... > New to Word 2007 would someone please explain to me how to insert Roman > Numerlas in my document? Just type them... I II III IV V VI VII VIII IX X XI etc etc. Type a number e.g. 21, select it and run the following macro Dim oRng As Range Set oRng = Selection.Range oRng.Fields.Add oRng, 34, oRng.Text & " \*Roman"...

adding space between columns in a chart
I am trying to customize a chart and I need to have a group of three lines (for pre-test days) then a space followed by a single line for the test day. I need to be able to accomplish this but also have a legend for these. have you tried having an empty cell in your data series for the space? "merritaf" wrote: > I am trying to customize a chart and I need to have a group of three lines > (for pre-test days) then a space followed by a single line for the test day. > I need to be able to accomplish this but also have a legend for these. ...

Insert trigger
Looking for some advice on SQL 2005. I have a table that will usually be populated by an SSIS package. I want to set the "loaddate" column to the current time after a record is inserted. Should i do this via trigger or should i just build a step in the SSIS package to update the column after the file loads? If trigger is the way to go, what is the syntax to create the after insert trigger? Thanks in advance. You can create a default constraint on the table set to CURRENT_TIMESTAMP. That will handle the automatic date assignment without any need for coding. -...

inserting hrs and minutes
I have a cell in my time card that displays total weekly time -ex- "40:15" is there a way to make it more like this...40hrs,15mins -- Message posted from http://www.ExcelForum.com Use a custom format hh"hrs",mm"mins" -- Regards, Peo Sjoblom "-Brian-H- >" <<Brian-H-.110wgs@excelforum-nospam.com> wrote in message news:Brian-H-.110wgs@excelforum-nospam.com... > I have a cell in my time card that displays total weekly time -ex- > "40:15" is there a way to make it more like this...40hrs,15mins ? > > > ...

insert an interactive excel file into word web page
I'm trying to insert a excel file into a word document with text, and then save it was as a web page, but I want to keep the excel part interactive. Any ideas? ...

Insert | File > Attachmnet-Button Drop Down ;What is the difference between Insert and Insert As Attachmnet
re: "Outlook2003, File-Insert-Options" On making new-email with Attachment-File(s), ** File Menu | Insert | File >>> (Brows and select File to insert ) then we can see the button "Insert", and write side Drop Down Arrow lower-right side of Dialog Box; If it clicked, we can see three options as follows: ** Insert Insert as text Insert as Attachment I can not recognize/understand the difference between "Insert" and "Insert as Attachment" *** What is the difference between Insert and Insert As Attachment ? I would appreciate y...

How do I print a one page spreadsheet multiple time, each with i.
How do I print a one page spreadsheet multiple time, each with its own page number You might want to try this. I used the preview feature. You can use print. There are may be techniques to setup one print call with new page numbers. Option Explicit Public Sub Printsheet() Dim Counter As Integer For Counter = 1 To 5 Call PrintSetup(Counter) ActiveWindow.SelectedSheets.PrintPreview Next Counter End Sub Sub PrintSetup(PageNumber As Integer) With ActiveSheet.PageSetup .PrintTitleRows = "" .PrintTitleColumns = "&...

Inserting Hyperlinks in a Protected Sheet
Hi I run Excel 2000 and I have a protected worksheet that I share wit users in my organisation. I want to allow the insertion of a hyperlin to a specific file type within a specified directory on our server. 3 Questions: 1.Protection on disables the insert hyperlink command. Can this b overcome with worksheet activate code? 2.Can I limit the types of files (preferably by requiring the file t meet a mask format eg "z-*.xls")? 3.Can I limit the directory that can be linked, by referring to pathname stored in a cell on the active sheet? Would appreciate your suggestions. Thanks S...

Creating mulitple asset cards from one purchasing invoice -
When creating muliple asset cards from one purchasing invoice, the balance available to create assets randomly disappears. Example: I purchased 4 items on one invoice, each for $2,960. I needed to set each up as a separate asset. I set up the first two assets, no problem, by changing the acquisition cost on the Asset Purchase screen to the cost of the one item. When I went to set up asset #3, I noted that the dollar amount remaining was exactly enough for asset #3, with nothing remaining for asset #4. I set up asset #4 to properly relieve my clearing account, but the automatic li...

Insert with a where condition
Hi, sql 2005 I have an insert statement that is ignoring the where condition. That is, I want to insert records when they do not already exist in the destination table. INSERT INTO dbo.tblmnuGroupPerm ( gId ,mtfID ,... ) SELECT @gID ,mtfID ,... FROM dbo.locmnuTabFunction AS ltf WHERE ltf.mtfID NOT IN ( SELECT gp.mtfID FROM dbo.tblmnuGroupPerm AS gp WHERE gp.gId=@gID AND gp.Deleted=0 ) Any ideas or recommendations appreciated :-) Many thanks, Jonathan It's OK... <oops "redFace">I did not correctly se...

How to copy specific columns until end of data
I'm trying to import data from 2 workbooks into a summary (combination) workbook. The trouble I'm having, is I want to import only certain columns and have excel know to stop at the last row with data. For example, from Workbook1 I want to import columns A, B, C, F, and G (from Sheet2). I want it to copy up to the last row containing any data--right now that's row 1046, but next month it could be row 1267. In workbook2 I'm fine with it copying the CurrentRegion--all columns are important. BUT, it doesn't include the title/category heads in the first row (Salesperson, ...

Calc Field to list invoices paid by same check on one line of repo
Hi I have a customer who wanted a check dump file to send to their bank. Once the bank receives the file (in txt or tab delimited), they will use the infomration to actually print the checks for the customer. (This is not a positive pay file situation.) I was able to take one of the check forms and modify it to get all the data required by the bank. I am running into a snafu with getting it down to one line per check with multiple invoices listed one one line. It is listing the total check and one line per each invoice paid by the check: Example: Ck 2345 for $800.00 -...

Insert
I want to overtype in a Publisher text box. I find I can only insert. The "insert" key doesn't do anything. ...

how to insert data in a table
Hi Exprets; I am creating an access database in which I want to insert data in already created table. Kindly help. Regards, Vikky Vikky <love.excel@gmail.com> wrote in news:1194124711.012302.269990 @e34g2000pro.googlegroups.com: > Hi Exprets; > > I am creating an access database in which I want to insert data in > already created table. > > Kindly help. > > Regards, > > Vikky > Data from where? Do you want to import it from excel, from a text file, copy it from another table or type it in manually? -- Bob Quintal PA is y I've altere...

How do you insert page numbers larger than 1000?
I have my purchase orders set up as a Publisher document. When our organization upgraded from Publisher 2000 to Publisher 2002, the new version set parameters on the page numbers. This was one of those things that worked just fine in the previous version... Does anyone know how to turn it off or change it? Hi mregen (mregen@discussions.microsoft.com), in the newsgroups you posted: || I have my purchase orders set up as a Publisher document. When our || organization upgraded from Publisher 2000 to Publisher 2002, the new || version set parameters on the page numbers. This was one of those...

insert downloads into power point
i downloaded an application called "BioDigital Simulator" of an animated cleft lip/palate surgery and need it put into my power point presentation, but can't fiugre out how to do so.... very frustrating... What kind of file is this application? Is it a video? If so, what kind? MPEG? AVI? MOV? Or is it an EXE file? Something else? Which version of PPT are you using? -- Echo [MS PPT MVP] http://www.echosvoice.com What's new in PPT 2010? http://www.echosvoice.com/2010.htm Fixing PowerPoint Annoyances http://tinyurl.com/36grcd PowerPoint 2007 Complete Makeover...

Insert dataset to another database
I'm posting this to this group also since it pertains to queries, primarily. Hello, Using VB6/ADO, I'm thinking I can create a recordset and insert it into another table in a different Jet database, all within the execution of a single query. But, I can't seem to get it to work, even in an experiment in Access 2K. My sql in Access 2K: SELECT D.lorder as Ord, A.Lorder FROM [;Database = C:\MyDocuments\Acc2K\Wrk.mdb].OrdersData as A INNER JOIN [;Database = C:\Access\Work\Sales06.mdb].Detl1 as D On D.Lorder = a.lorder WHERE ((D.fg)= 'MXX-NC' Or (D.fg)= 'MXX.NC')...

Insert a blank row
Hi, I need some help to insert a blank row in a range where column A has a series of dates. There will be several of the same dates and I need to both sort the dates and then insert the blank row at the end of each sequence. In the blank row I need to total figures that will be in columns B through to G. Thanks, Jim S Hi Jim maybe an easier solution 1. Sort your data (use 'Data - Sort', e.g., column A ascending) 2. Use 'Data - Subtotals' This will insert a row after each date and calculate subtotals automatically for you HTH Frank anon wrote: > Hi, > I need some...

schedule plan for every 3 month in one sheet excel
hi there i would like to ask you , how i can do in excel schedule plan for 3 month in one sheet In a chart?? What do you have so far? "jameela" <jameela @discussions.microsoft.com> wrote in message news:D62F6B0C-D6E4-4E00-85BF-C191EEA7A60A@microsoft.com... > hi there > > i would like to ask you , how i can do in excel schedule plan for 3 month > in > one sheet ...

want to convert number to word (eg) 1 as one
I would like to convert automaticaly the numericals into word format fo example In excel If I type 100.00 ( it should type automatically (one hundre only). Is it available in excel. If anyone knows pls reply to my e-mail wintersc@vsnl.ne -- Message posted from http://www.ExcelForum.com It is not available by default, but this is an often-asked question in this forum. You may want to do a search and see if you find your answer. Otherwise, are you looking for a formula or a VBA macro? If you're looking to put the text in a different cell from the number, then a formula will work. If ...

How do I insert a letter into an existing word document?
I am working on a large document that I need to add several letters that are on our letterhead. If I cut and paste the letter, the letterhead header becomes skewed. This is just one issue I'm having with the document! Also need to know how to merge 3 separate documents together once I insert the letters that I need! Help! What do you mean by "skewed"? To preserve the data from the header of the document, you will need to insert it into a Section of its own separated from the rest of the document by Next page Section breaks before and after it with the headers...

How do I insert backround into my picture inserts?
Could you please elaborate on your question, and give us details such as your version of Publisher. -- Brian Kvalheim Microsoft Publisher MVP http://www.publishermvps.com This posting is provided "AS IS" with no warranties, and confers no rights. "TAMOS" <TAMOS@discussions.microsoft.com> wrote in message news:A1B3ABEC-F208-4A23-B695-9C0EEFBF649F@microsoft.com... > How to Compose a Good Newsgroup Post http://dts-l.org/goodpost.htm How to Act Smart on Usenet http://www.catb.org/~esr/faqs/smart-questions.html Getting Your Post Noticed - and Answered http:...

comma delimited not seperating into columns
Just updated Microsoft Service Pack 2, now my Excel won't seperate imported comma delimited into columns. Imported data comes with commas, but won't seperate into seperate columns. What can I do? Thanks Steve Try changing the incoming file to *.TXT if you are using *.CSV Excel's Text to Columns Wizard will open allowing you to separate. Gord Dibben Excel MVP On Tue, 5 Oct 2004 08:57:04 -0700, "STEVE" <STEVE@discussions.microsoft.com> wrote: >Just updated Microsoft Service Pack 2, now my Excel won't seperate imported >comma delimited into columns....

How to extract multiple rows based on data in one column
I work at an insurance brokerage where we can download payment statements in an Excel format. We would like to search a list of policy numbers (as a group vs. individually) and then extract the entire row the policy number falls in into another spreadsheet. Is there a way to do this? You would normally use VLOOKUP to do this, assuming the policy number is in the first column of your data - if not, then you would use and INDEX/MATCH combination. However, both VLOOKUP and MATCH will only find the first match - I'm a bit confused as your heading talks about extracting multiple rows, so do yo...