column heading

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi
i have a sheet having 52 columns and around 2000 rows
actually the data is imported from access table
therefore first row is occupied by the fields name
my question is how do i use these field names while coding in vba?
 
I had this data stating in A1
name account owing
smith a12 10
jones a22 20
liengme a33 30
macdonald a45 25



Here is a very simple subrountine to play with
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 07/08/2007 by Bernard V Liengme
'

'
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.CreateNames Top:=True, Left:=False, Bottom:=False, Right:= _
False
Range("A1").Select
MsgBox Application.Sum(Range("owing"))
End Sub
 
hi bernard
suppose the data is like this
amt1 amt2
5000 10000
and i have to write code as msgbox(row(n).amt1+row(n).am2)
 
Try this
'
' Macro1 Macro
' Macro recorded 07/08/2007 by Bernard V Liengme
'

'
Range("A1:C4").Select
Application.CutCopyMode = False
Selection.CreateNames Top:=True, Left:=False, Bottom:=False, Right:= _
False
Set amt1 = Range("amt1")
Set amt2 = Range("amt2")

MsgBox amt1(2) + amt2(2)


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top