Forum Discussion

KAM_Mumin's avatar
KAM_Mumin
Brass Contributor
Sep 02, 2022

MS Excel VBA

Hi Everyone!

Here I want to take the values of the Remarks column from the sheet name "AS cs S" to any cell like G3 of the sheet name "AS Sanitary" but here some conditions I apply which are:

1. Filter the "Status" column of the sheet name "AS cs S" by only the rows where "Ok" is placed.

2. After "Status" column filtered then selecting both columns of "Remarks" & "Status" for clearing contents of "Ok" related rows.

3. After clearing then again filter the "Status" column by showing all rows with blanks.

4. Then filter the "S/N" column as ascending.

5. Then copy the "Remarks" column and past values to another sheet like sheet name "AS Sanitary" cell G3.

The error or can say the macro errors is when I run it it works but the column "Remarks" of sheet name "AS cs S" will clear with the all rows values...but just I want to clearing the rows which is related with rows value "Ok" of column "Status" and  the other values will be stay on the row....

Please if any of you can help me or have a solution then plz reply...

 

  • DexterG_III's avatar
    DexterG_III
    Iron Contributor

    KAM_Mumin If I understand correctly, all cells are being cleared after the filter is applied.  And therefore, nothing remains to be copied in subsequent steps.  

     

    In your code, just before selection.clearcontents,

    insert Selection.SpecialCells(xlCellTypeVisible).Select.  

     

    This will ensure that only the cells not being filtered will be cleared.  

     

    Hope this helps.  

    • KAM_Mumin's avatar
      KAM_Mumin
      Brass Contributor

      DexterG_III 

      dear that is not working when i insert this,,, if you have another solution then plz send me,,

       

Resources