Hi, currently I'm working on a VBA code that I have to perform multiple task in a sheet namely "Sheet1".
I have wrote a code on it, but I feel like it is to length and need a way to refine it.
This is my code:
The main reason why I keep repeating "Sheets("Sheet1").select" is because before this code, I actually have another code that need it to copy data from other sheets by refer to its header column. And when I didn't add "Sheets("Sheet1").select", it keep runs error.
I have wrote a code on it, but I feel like it is to length and need a way to refine it.
This is my code:
VBA Code:
Sub formatsheet()
'removedot
Sheets("Sheet1").Select
Sheets("Sheet1").Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Replace what:=".", replacement:=" ", lookat:=xlPart, searchorder:=xlByRows, MatchCase:=False, searchformat:=False, ReplaceFormat:=False, formulaversion:=xlReplaceFormula2
'insert I
Sheets("Sheet1").Select
Sheets("Sheet1").Range("B2").Select
Selection.Value = "I"
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select
'Fill country
Sheets("Sheet1").Select
Sheets("Sheet1").Range("G2").Value = "USA"
Range("G2").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("G2:G" & Range("A" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select
End Sub
The main reason why I keep repeating "Sheets("Sheet1").select" is because before this code, I actually have another code that need it to copy data from other sheets by refer to its header column. And when I didn't add "Sheets("Sheet1").select", it keep runs error.