Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dow Dow is offline
external usenet poster
 
Posts: 31
Default Insert Column based on data in Row.

I was unable to find the answer to this question. I know it is out
there but for some reason my search results are not providing what I
need lately.

I have a spreadsheet that varies in the number of columns (A through
Whatever). I want to use VBA to look at Row 2 and anywhere it says a
word or phrase (let's say "happy summer") I want to be able to insert
another column.

For example if D2 says "happy summer" I want to insert a column on F
and if, if B2 says "happy summer" I would want to insert a column on
C.

Any thoughts out there? You guys and gals are always very helpful.

Thank you,

Dow.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Insert Column based on data in Row.

Is there any logic with which to determine where to insert a column if the
specified data is in some other column? Do you have a list of texts to look
for or just one? HTH Otto
"Dow" wrote in message
...
I was unable to find the answer to this question. I know it is out
there but for some reason my search results are not providing what I
need lately.

I have a spreadsheet that varies in the number of columns (A through
Whatever). I want to use VBA to look at Row 2 and anywhere it says a
word or phrase (let's say "happy summer") I want to be able to insert
another column.

For example if D2 says "happy summer" I want to insert a column on F
and if, if B2 says "happy summer" I would want to insert a column on
C.

Any thoughts out there? You guys and gals are always very helpful.

Thank you,

Dow.



  #3   Report Post  
Posted to microsoft.public.excel.programming
Dow Dow is offline
external usenet poster
 
Posts: 31
Default Insert Column based on data in Row.

On Aug 3, 3:50*pm, "Otto Moehrbach"
wrote:
Is there any logic with which to determine where to insert a column if the
specified data is in some other column? *Do you have a list of texts to look
for or just one? *HTH *Otto"Dow" wrote in message

...



I was unable to find the answer to this question. *I know it is out
there but for some reason my search results are not providing what I
need lately.


I have a spreadsheet that varies in the number of columns (A through
Whatever). *I want to use VBA to look at Row 2 and anywhere it says a
word or phrase (let's say "happy summer") I want to be able to insert
another column.


For example if D2 says "happy summer" I want to insert a column on F
and if, if B2 says "happy summer" I would want to insert a column on
C.


Any thoughts out there? *You guys and gals are always very helpful.


Thank you,


Dow.- Hide quoted text -


- Show quoted text -


At this time it is just the one text "happy summer". If I choose to
add more I think I know how to do that with named ranges based on a
previous workbook I built.

At this time the data will be in row 2 without exception. The columns
can vary from 5 to 70+. The logic should be - If row 2 Column X
(Columns will vary and there will be more than one of them with the
required text) says "happy summer" insert column on the next position
or Y in this case.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Insert Column based on data in Row.

This little macro will look in all the entries in row 2, and if the entry is
"happy summer", it will insert a new blank column immediately to the right.
HTH Otto
Sub InsertColumns()
Dim rRow2 As Range
Dim c As Long
Set rRow2 = Range("A2", Cells(2, Columns.Count).End(xlToLeft))
For c = rRow2.Count To 1 Step -1
If rRow2(c) = "happy summer" Then
rRow2(c + 1).EntireColumn.Insert
End If
Next c
End Sub
"Dow" wrote in message
...
On Aug 3, 3:50 pm, "Otto Moehrbach"
wrote:
Is there any logic with which to determine where to insert a column if the
specified data is in some other column? Do you have a list of texts to
look
for or just one? HTH Otto"Dow" wrote in message

...



I was unable to find the answer to this question. I know it is out
there but for some reason my search results are not providing what I
need lately.


I have a spreadsheet that varies in the number of columns (A through
Whatever). I want to use VBA to look at Row 2 and anywhere it says a
word or phrase (let's say "happy summer") I want to be able to insert
another column.


For example if D2 says "happy summer" I want to insert a column on F
and if, if B2 says "happy summer" I would want to insert a column on
C.


Any thoughts out there? You guys and gals are always very helpful.


Thank you,


Dow.- Hide quoted text -


- Show quoted text -


At this time it is just the one text "happy summer". If I choose to
add more I think I know how to do that with named ranges based on a
previous workbook I built.

At this time the data will be in row 2 without exception. The columns
can vary from 5 to 70+. The logic should be - If row 2 Column X
(Columns will vary and there will be more than one of them with the
required text) says "happy summer" insert column on the next position
or Y in this case.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a Macro to Insert a number into a column based on criteria [email protected] Excel Programming 3 August 8th 07 06:14 PM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Programming 2 December 30th 06 06:23 PM
Insert Blank Row Based on Value in Column A Kevin D Excel Programming 1 November 24th 06 01:17 AM
copy and insert entire row based on integer in column A Dave A Excel Programming 8 June 26th 06 02:18 AM
Insert duplicate rows based on numeric value in column Nu2Excel Excel Discussion (Misc queries) 2 September 24th 05 04:31 PM


All times are GMT +1. The time now is 02:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"