Home > Net >  Is there a way I can reference only visible cells when dealing w a variable? I don't want to co
Is there a way I can reference only visible cells when dealing w a variable? I don't want to co

Time:01-14

my lrow is correct... But I want my Cells(I, matl.Column).Value to only call the visible cells. Right now its calling all cells. I've tried:

Cells.SpecialCells(xlCellTypeVisible).Select(I, matl.Column).Value and that just gives me errors.

Lmk if this is even possible! Here's my code below!

lrow = Workbooks(tmpwb).Worksheets(mm).AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count - 1

For I = 3 To lrow
    'For j = 0 To 16
         session.findById("wnd[0]/usr/sub:SAPMM07M:0421/ctxtMSEG-MATNR[" & I - 3 & ",7]").Text = Cells(I, matl.Column).Value   

         

Next I

CodePudding user response:

Maybe something like this:

Dim col as Range, rngVis As Range, c As Range, I As Long

Set col = Workbooks(tmpwb).Worksheets(mm).AutoFilter.Range.Columns(1)
Set rngVis = col.SpecialCells(xlCellTypeVisible)

I = 3
For Each c In rngVis.Cells
    If c.Row > col.Cells(1).Row Then 'skip the header
    '   `I` below may need to be `c.row-3` ?
    session.findById("wnd[0]/usr/sub:SAPMM07M:0421/ctxtMSEG-MATNR[" & I - 3 & ",7]").Text = _
       c.EntireRow.Columns(matl.Column).Value
    
    I = I   1
    End If
Next c
  •  Tags:  
  • Related