MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Jan 14th, 2002, 01:29 PM   #1
Bagsy Baker
New Member
 
Join Date: Feb 2002
Location: Sackville
Posts: 39
Default

Thanks daleyman, that did the trick. I tried similar code with no sucess, but yours did the trick. I knew it had to be something simple, but I kept going around the proper solution. Thanks for the help!!!
Bagsy Baker is offline   Reply With Quote
Old Apr 14th, 2002, 09:30 AM   #2
Bagsy Baker
New Member
 
Join Date: Feb 2002
Location: Sackville
Posts: 39
Default

I have a DAT file that I am bring into Excel to modify. The field seperators are commas. When I have the required changes done, I want to save as text file, but need to put the commas back in (for import requirements in the next software package). I thought I had seen a tip to insert a blank column between all existing columns, but can't find it using search, and am getting frustrated trying to recreate it. Can anyone point me in the right direction to find the tip or tell me how to set the macro up?
Bagsy Baker is offline   Reply With Quote
Old Apr 14th, 2002, 09:32 AM   #3
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Are there a set number of columns?
How about saving as a csv file?
Comma Seperated Values
Tom


[ This Message was edited by: TsTom on 2002-04-14 08:35 ]
Tom Schreiner is offline   Reply With Quote
Old Apr 14th, 2002, 09:37 AM   #4
daleyman
Board Regular
 
Join Date: Mar 2002
Location: London, UK
Posts: 167
Default

recent topic over last 24 hours...

click here !

.. also, if you cannot adjust this code to do it for you, are you asking for just a macro to insert a blank column every other column?


__________________

<table style="background-color:#0e54be" cellspacing="1" cellpadding="2"><td style="background-color:#ceffff;font-family:arial;color:#072c63;font-size:8pt;">***DALEY** :P**</td></table>
daleyman is offline   Reply With Quote
Old Apr 14th, 2002, 10:31 AM   #5
Bagsy Baker
New Member
 
Join Date: Feb 2002
Location: Sackville
Posts: 39
Default

I tried the CSV format, but the program to import into will not accept it. The quotes for text fields are already brought over when I import the data into Excel. I have 16 columns, some of them blank, that require a comma to seperate. A macro to insert 15 columns is all that is required as I have the rest of the code set up already. Why is it that the simple things always seem to cause the most problems?


[ This Message was edited by: Bagsy Baker on 2002-04-14 09:32 ]
Bagsy Baker is offline   Reply With Quote
Old Apr 14th, 2002, 11:52 AM   #6
daleyman
Board Regular
 
Join Date: Mar 2002
Location: London, UK
Posts: 167
Default

still don't really understand the question. If its just alternate columns needing to be inserted, how about:



Sub insert_column_every_other()
For colx = 2 To 30 Step 2
Columns(colx).Insert Shift:=xlToRight
Next
End Sub


sorry, is this what you mean?
__________________

<table style="background-color:#0e54be" cellspacing="1" cellpadding="2"><td style="background-color:#ceffff;font-family:arial;color:#072c63;font-size:8pt;">***DALEY** :P**</td></table>
daleyman is offline   Reply With Quote
Old Apr 14th, 2002, 12:01 PM   #7
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Quote:
On 2002-04-14 10:52, daleyman wrote:
still don't really understand the question. If its just alternate columns needing to be inserted, how about:



Sub insert_column_every_other()
For colx = 2 To 30 Step 2
Columns(colx).Insert Shift:=xlToRight
Next
End Sub


sorry, is this what you mean?
I don't know exactly what the OP wants, but I don't think your code will do eactly what *you* want here.

If you are inserting columns and shifting to the right, it is much better to go from right to left, as the columns will not fall out of sync with your colx value. It will be very difficult to keep track of the columns/count this way.

Sub insert_column_every_other()
For colx = 30 To 2 Step -2
Columns(colx).Insert Shift:=xlToRight
Next
End Sub

will be better suited for this, much like when you delete rows, you work from bottom to top.

Bye,
Jay
Jay Petrulis is offline   Reply With Quote
Old Nov 10th, 2011, 10:33 AM   #8
chrisfensome22
New Member
 
Join Date: Nov 2011
Posts: 4
Default Re: Macro to Insert Column between Existing Columns

Hello,

Do you know how i would rework this so it works across more columns? and potentially add in 3 columns instead of just one?

thanks for the help

chris
chrisfensome22 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 01:01 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes