Dynamic Range

  • Thread starter Thread starter Patty2005
  • Start date Start date
P

Patty2005

I have a sheet called result and It has Products and Machines field
Machines.I am trying to count the number of columns the machines
have.Everytime I insert column my range changes.I have to insert column
if the depending on some validation.Default is two columns.That works
fine.When I insert another column it should give the count as 3 not 2.
I don't know if I should use Dynamic range or not.If I have to please
help me with the code.

See attached document and the code comments,Thanks!!!!

Attachment filename: help.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=633910
 
Hi,

Sub TEST()

cnt = ActiveSheet.Range("D1").MergeArea.Columns.Count
MsgBox "Number of columns are " & cnt

End Sub


(In your file, D1 is the first cell of columns the Machines have.)


--
Regards,
Soo Cheon Jheong
_ _
^¢¯^
--
 

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