Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,560
Default Insert Column after specific text title the new column and add

Hi Dave,

I replied prior to testing it, the formula is already there, i changed the 5
to 1000, it really works great, thank you for your great work.

"David" wrote:

Hi Dave,

Thank you for taking the time and writting the codes, the formula will
differ, however it could be as simple as +the value in amount column/1000.
can you please help me include that in the code?

"Dave Peterson" wrote:

I'm guessing that you're looking at a specific row (row 1???) that contains
those headers?

And you didn't share what that formula would be!

Option Explicit
Sub testme()

Dim FoundCell As Range
Dim wks As Worksheet
Dim myStr As String
Dim LastRow As Long

myStr = "Amount"

Set wks = Worksheets("Sheet1")

With wks
'formula will fill rows 2 to the last used cell
'in column A
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With .Rows(1)
Set FoundCell = .Cells.Find(What:=myStr, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With

If FoundCell Is Nothing Then
MsgBox myStr & " wasn't found!"
Else
.Cells(1, FoundCell.Column + 1).EntireColumn.Insert
.Cells(1, FoundCell.Column + 1).Value = "New Column"
.Range(.Cells(2, FoundCell.Column + 1), _
.Cells(LastRow, FoundCell.Column + 1)).FormulaR1C1 _
= "=rc[-1]/5"
End If

End With
End Sub



David wrote:

Hi,

I am trying to create a macro that will add a column after a specific text
and title the column add formula,

example, i have a sheet with 50 columns one of which is titled "Amount" i
want the macro find that title and add a column to the right of it and title
it "new column" and add a formula.

really appreciate any help.

thanks
David


--

Dave Peterson

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
Insert pagebreak when a specific word appears in a column. Neal Excel Discussion (Misc queries) 4 October 27th 08 11:17 PM
MAX value in column to use with text for title rc Excel Discussion (Misc queries) 6 July 6th 07 08:26 PM
Named range=Column title,comumn title in cellB6 use B6in equation Graham Excel Discussion (Misc queries) 2 July 21st 06 10:03 AM
sum of 1 column if info in another = specific text blackstar Excel Discussion (Misc queries) 17 February 4th 06 01:44 PM
Sumif based on column A and title of another column Rusty Excel Discussion (Misc queries) 7 October 19th 05 12:28 AM


All times are GMT +1. The time now is 05:04 PM.

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

About Us

"It's about Microsoft Excel"