0

I have a small problem my macro is the following :

For i = 8 To 33

Set Namesheet = Workbooks("XXX.xlsm").Worksheets("Macro").Range("M" & i)

(.....)

Sheets(Namesheet).Select

But instead of giving me 603 (that is the name of my sheet), it gives me "603".

Any thing I could do to solve that ?

Thanks in advance

Damian
  • 5,152
  • 1
  • 10
  • 21
  • 2
    [Don't `Select`](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba). If `Namesheet` is declared `As Worksheet`, which it should be, then just work with `Namesheet`. – BigBen Feb 25 '20 at 17:45
  • 1
    First of all, `Set Namesheet` looks like an object to me, is `Namesheet` declared as `Worksheet` or `Object`? If so, you can use `Namesheet.Select`thought, don't select. – Damian Feb 25 '20 at 17:46
  • 1
    Namesheet appears to reference a cell which means you need to access the `.Value` in this case. `Sheets(Namesheet.Value).Select` although, as stated, don't select :) so just `Sheets(Namesheet.Value).[What you really want to do]` – urdearboy Feb 25 '20 at 17:53
  • Thank you so much ! its solved thanks to Value ! :) – Andreas Cayla Feb 25 '20 at 17:56

0 Answers0