Forum Discussion

Lorenzo Kim's avatar
Lorenzo Kim
Bronze Contributor
Jul 14, 2018
Solved

runtime error 1004 : Method range of object - 'Global' failed

How do I correct this?

(kindly see images)

many many thanks

 

 

  • Matt Mickle's avatar
    Matt Mickle
    Jul 17, 2018

    You can drop the WorksheetFunction portion for easier readability:

    New_text = Application.Substitute(Cell_reference,"TOTAL","")
  • Luciano_Lago's avatar
    Luciano_Lago
    Copper Contributor
    for me the msg error appeas at the time I am calling F10 key

    ' RUN_FORREST_RUN Macro
    '

    '
    ChDir "Y:\Luciano"
    ActiveWorkbook.SaveAs Filename:= _
    "Y:\Luciano\Segment Report Conso Excel Link.xlsb", FileFormat:=xlExcel12, _
    CreateBackup:=False


    Sheets("CoA").Select
    Range("CoA[[#Headers],[ACCOUNT NUMBER]]").Select
    Application.Run Range("cc.F10")
    Cells.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    • Lorenzo Kim's avatar
      Lorenzo Kim
      Bronze Contributor

      Mr. Chan

      Here I am again, pardon for the bother..

      kindly help with the small snippet below

      I wish to erase in a range of column the word "Total" in a cell.

      in EXCEL it is =left(cellText, len(cellText)-5)

      How do I write it in vba?

      many many many thanks

       

       

      Sub RemoveWordTotal()

      Application.ScreenUpdating = False
      Dim i As Long
      For i = Cells(Rows.Count, "B").End(xlUp).Row To 2 Step -1

      ' remove the word total inside a column range cell

      Next i

      Application.ScreenUpdating = True

      End Sub

      • Man Fai Chan's avatar
        Man Fai Chan
        Iron Contributor

        Dear Kim,

         

        I heard a worksheet function: "SUBSTITUTE" which can perform your task:
                  SUBSTITUE(A1,"TOTAL","")

         

        Cheers 

        Chan M F

    • Lorenzo Kim's avatar
      Lorenzo Kim
      Bronze Contributor

      Mr Chan

      I think it is -- the lastrow was 0!

      Thank you for your reply...

  • Haytham Amairah's avatar
    Haytham Amairah
    Silver Contributor

    Hi Lorenzo,

     

    The Cells function requires two arguments: RowIndex & ColumnIndex

    Both must be a number, not a text!

    You put the text "C" in the ColumnIndex, so try to replace it with 3 instead.

     

     

    Regards

Resources