Forum Discussion

nicholasajl's avatar
nicholasajl
Copper Contributor
May 31, 2020
Solved

Can anyone see the error in this VBA code?

Hello All,

 

I am very new to vba code. I am learning mainly by adapting existing macros.

 

On the screenshot here, you can see a line of code that isn't working.

 

This code, as a whole, creates a new sheet for each row of data.

I want to create a sparkline in cell A20. The problem is how to sourcedata range. It is always columns BK to CW, but I need to tell it how to use just one row. 

 

The &Rng.Row operation works on all other lines, but not here.

 

Can anyone help?

 

Thanks,

 

Nick

 

  • nicholasajl 

     

    Hi,

     

    Currently you are supplying a row reference to only the CW column of MasterSheet!BK:CW, but the BK column also requires a row reference:

     

    "MasterSheet!BK" & Rng.Row & ":CW" & Rng.Row

     

    Regards

3 Replies

  • Jos_Woolley's avatar
    Jos_Woolley
    Iron Contributor

    nicholasajl 

     

    Hi,

     

    Currently you are supplying a row reference to only the CW column of MasterSheet!BK:CW, but the BK column also requires a row reference:

     

    "MasterSheet!BK" & Rng.Row & ":CW" & Rng.Row

     

    Regards

    • nicholasajl's avatar
      nicholasajl
      Copper Contributor

      Jos_Woolley 

       

      In minutes, you've fixed what I've spent many hours trying to sort.

       

      I'm so grateful!

       

      Many thanks,

       

      Nick 🙂

      • Jos_Woolley's avatar
        Jos_Woolley
        Iron Contributor

        nicholasajl 

         

        You're very welcome! You're doing the right thing by trying to adapt code yourself in order to develop your understanding of VBA. Best way to learn, in my opinion.

         

        Regards

Resources