Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding column title


This is regarding my old query only. I got the help through my earlie
post and after making some modifications, I have made written th
following code.


Sub test()

Dim Setup As Worksheet
Dim Inputf As Worksheet
Dim Output As Worksheet
Dim setrng As Range
Dim list As Range
Dim x As Long
Dim nwb As Workbook

Set Inputf = Workbooks("Input.xls").Worksheets(1)
Set Setup = Workbooks("Input.xls").Worksheets("Setup")
Set nwb = Workbooks.Add
Set Output = nwb.Worksheets(1)
Set setrng = Setup.Range("A1").CurrentRegion.Columns(1).Cells
x = 1
For Each list In setrng
Inputf.Columns(list.Value).Copy Destination:=Output.Columns(x)
x = x + 1
Next
nwb.SaveAs Filename:="Output.xls"
End Sub


Now I want to do some modifications in this. I want to check that, i
anyone has added the column title in the setup tab then it shuld tak
that perticulat title for the specified column. Else it will take th
original title of the column.
for eg., If I specify "a - Name", then it should take the title for th
column in "Output.xls" as "Name", and if I specify only "a", then i
should take the original title of the column.
How to do this

--
reen
-----------------------------------------------------------------------
reena's Profile: http://www.excelforum.com/member.php...fo&userid=3044
View this thread: http://www.excelforum.com/showthread.php?threadid=50160

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Adding column title

Sub test()

Dim Setup As Worksheet
Dim Inputf As Worksheet
Dim Output As Worksheet
Dim setrng As Range
Dim list As Range
Dim x As Long
Dim nwb As Workbook
Dim s as String, sName as String
Dim iloc as Long

Set Inputf = Workbooks("Input.xls").Worksheets(1)
Set Setup = Workbooks("Input.xls").Worksheets("Setup")
Set nwb = Workbooks.Add
Set Output = nwb.Worksheets(1)
Set setrng = Setup.Range("A1").CurrentRegion.Columns(1).Cells
x = 1
For Each list In setrng
iloc = Instr(1,list.Value,"-",vbTextCompare)
if iloc 0 then
s = trim(left(list.value,iloc-1)
sName = trim(mid(list.value,iloc+1,255))
else
s = trim(list.value)
sName = ""
end if

Inputf.Columns(s).Copy Destination:=Output.Columns(x)
if iloc 0 then Output.Cells(1,x).Value = sName
x = x + 1
Next
nwb.SaveAs Filename:="Output.xls"
End Sub

--
Regards,
Tom Ogilvy


"reena" wrote in
message ...

This is regarding my old query only. I got the help through my earlier
post and after making some modifications, I have made written the
following code.


Sub test()

Dim Setup As Worksheet
Dim Inputf As Worksheet
Dim Output As Worksheet
Dim setrng As Range
Dim list As Range
Dim x As Long
Dim nwb As Workbook

Set Inputf = Workbooks("Input.xls").Worksheets(1)
Set Setup = Workbooks("Input.xls").Worksheets("Setup")
Set nwb = Workbooks.Add
Set Output = nwb.Worksheets(1)
Set setrng = Setup.Range("A1").CurrentRegion.Columns(1).Cells
x = 1
For Each list In setrng
Inputf.Columns(list.Value).Copy Destination:=Output.Columns(x)
x = x + 1
Next
nwb.SaveAs Filename:="Output.xls"
End Sub


Now I want to do some modifications in this. I want to check that, if
anyone has added the column title in the setup tab then it shuld take
that perticulat title for the specified column. Else it will take the
original title of the column.
for eg., If I specify "a - Name", then it should take the title for the
column in "Output.xls" as "Name", and if I specify only "a", then it
should take the original title of the column.
How to do this?


--
reena
------------------------------------------------------------------------
reena's Profile:

http://www.excelforum.com/member.php...o&userid=30440
View this thread: http://www.excelforum.com/showthread...hreadid=501603



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding column title


Hi,

for this instad of writing "a - Name", if I want to specify "a in the
first column" and "Changed title in the other column" then how will I
modify the code?

Reena


--
reena
------------------------------------------------------------------------
reena's Profile: http://www.excelforum.com/member.php...o&userid=30440
View this thread: http://www.excelforum.com/showthread...hreadid=501603

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
Adding subtitles to chart title BrendaC New Users to Excel 2 April 3rd 23 07:36 PM
Adding Title to Secondary Axis Office 2003 C Kreig Charts and Charting in Excel 3 November 4th 08 04:08 PM
Named range=Column title,comumn title in cellB6 use B6in equation Graham Excel Discussion (Misc queries) 2 July 21st 06 10:03 AM
adding link to chart title using VB Ken Shaffer Excel Programming 1 November 8th 05 12:00 AM
Adding a title to a worksheet. How/Where? XPC465 New Users to Excel 1 March 25th 05 03:56 PM


All times are GMT +1. The time now is 09:26 AM.

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"