Home > Software engineering >  When using the variable, program is invalid, refer to the great god
When using the variable, program is invalid, refer to the great god

Time:09-17

When my program is
Sub kk ()
The Columns (" A ".) the Replace What:="(I)," Replacement:=", "LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
End Sub
Programming work, but when I introduced variable
Sub kk ()
For I=1 To 10
The Columns (" A ".) the Replace What:="(I)," Replacement:=", "LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, MatchByte:=False, SearchFormat:=True, ReplaceFormat:=True
Next I
End Sub
Excel data in the table does not change, refer to the great god

CodePudding user response:

The Columns (" A ".) the Replace What:="(I)"

Problem here, you pass in a fixed string, rather than a variable
The Columns (" A ".) the Replace What:=STR (I)...
Have a try

CodePudding user response:

The Columns (" A ".) the Replace What:="(I)" to the Columns (" A "). The Replace What:=STR (I)
  •  Tags:  
  • VBA
  • Related