• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

"Count Megearea columns" code is not working

shiva_raj

New Member
HI



I wrote a VBA code by using Sumifs function. in this code i find out starting column number (for each category box), ending column number for merged cell by using #selection.columns.count# in 2nd row & 11th row (first attachment). sometimes this formula returns 1 even though there are 6 cells in Mergearea. When we run the code by using F5, this formula is not working properly. in the summary sheet (first attachment) few violet BOXES were not getting result. please help me.

thank you in advance.

Regards
shiva
 

Attachments

  • K&S-Sales_MTD_Report_For_test.xlsm
    41.4 KB · Views: 2
  • Activation_Details.Xls
    393.5 KB · Views: 2
you seem to have about 5 places with:
n = Cells(2, sc).MergeArea.Columns.Count
where Cells is unqualified.
Try changing all instances to:
n = .Parent.Cells(2, sc).MergeArea.Columns.Count

As an aside, perhaps
lr = Worksheets("Raw").Cells(Rows.Count, 1).End(xlUp).Row
might be better being:
lr = Worksheets("BOXES").Cells(Rows.Count, 1).End(xlUp).Row
 
Back
Top