VBA Excel Name Sheet as Variable

Joined
Dec 27, 2010
Messages
2
Reaction score
0
Hello,
I am trying to make a loop where sheet names are variables.
In this program, I want to find the column number of a (a is a title of a table, always line 1, no more than 100 columns ) in sheet b

function colnumber (a, b)
For i=1 to 100
is Sheets(b).cells(1,i).Value=a
then colnumber=i
End if
Next
end function

But it looks it never want to recognize b.

I am stuck....any help?...would be fantastic!

Frederoc
 
Joined
Dec 27, 2010
Messages
2
Reaction score
0
Hi,

after some more research, it partly works.

if I use the function like =colnumber("Name";"Portefeuille")
Portefeuille is the name of a spreadsheet, and Name is what is in a cell in first line,
then it work.
if I use colnumber(A2;A3)
Where A2 value is "Name" (or Name)
and A3 value is "Portefeuille" (or Portefeuille)
Then it does not work.

I don't understand
 

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

Top