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

hi
i have a sheet populated from a dbf(foxPro) file
and my first row contains field names
on the bais of that i want to refer entire column by relative field name
how to achieve this
thanks.
--
hemu
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default naming the column

you cant ,, all you can do is use row 1 as a header row

"Hemant_india" wrote:

hi
i have a sheet populated from a dbf(foxPro) file
and my first row contains field names
on the bais of that i want to refer entire column by relative field name
how to achieve this
thanks.
--
hemu

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


hi Hemu,

I'm not sure if this is exactly what you want but it may give you som
ideas for trying...

nb: this macro is based on the assumption that:
* all the cells in the header row are unique
* there are no blank rows wihin the data (if there are, the named rang
will be inaccurate)
* and the data starts in column A & is continuous across a # o
columns.
Also, be aware that I have not added any error checking.

Are you familar with maros?
If so, put the following in an appropriate module:

Sub CreatingNamesBasedOnHeaders()
Dim i As Long
Dim NumOfCols As Long
Dim RelativeFieldName As String
Dim CurrentSheet As String
NumOfCols = Cells(1, Columns.Count).End(xlToLeft).Column
CurrentSheet = ActiveSheet.Name
For i = 1 To NumOfCols
RelativeFieldName = Cells(1, i)
ActiveWorkbook.Names.Add Name:=RelativeFieldName, RefersToR1C1:= _
"=OFFSET('" & CurrentSheet & "'!R2C" & i & _
",0,0,COUNTA('" & CurrentSheet & "'!R2C" & i & ":R65536C" & i
"))"
Next i
MsgBox NumOfCols & " names have been set up in the current sheet.", _
, "NAMES CREATED BASED ON HEADERS"
End Sub


If not, have a read o
http://www.mvps.org/dmcritchie/excel/getstarted.htm and then open th
Excel file that you want to add the names to, press [alt + F11] (t
open the VB Editor), [alt + i + m] (to add a module), and paste th
above macro into the resulting window. Press [alt + F4] to close the V
Editor.

Now, whenever you want to run this macro on a sheet in this workbook
press [alt + F8] & choose "CreatingNamesBasedOnHeaders" from the lis
of macros. If it the macro will be used in a range of workbooks I'
store it in your personal.xls file (refer to Dave McRitchie's page fo
details).

hth
Rob Brockett
NZ
Always learning & the best way to learn is to experience..

--
broro18
-----------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...fo&userid=3006
View this thread: http://www.excelforum.com/showthread.php?threadid=54415

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
naming a column mariekek5 Excel Discussion (Misc queries) 3 February 19th 10 12:01 PM
naming a column wolffjrs Excel Discussion (Misc queries) 2 July 6th 09 09:14 AM
Naming of column index Freshman Excel Worksheet Functions 2 October 30th 07 07:57 AM
naming a grouped column Amie Excel Worksheet Functions 0 July 25th 06 10:43 PM
Naming Row/column in same cell? Bob Setting up and Configuration of Excel 1 July 13th 06 03:58 PM


All times are GMT +1. The time now is 10:50 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"