-3

I have a working VBA script which currently replaces all dots by commas (posted below). However I would the script avoid the first two rows and change everything else. What would be the best and easiest way to do this? I have only found solutions where you have to set a range and but I want it to work for all excel sheets regardless of the number of rows or columns.

Sheets("Sheet1").Select
Cells.Replace what:=".", Replacement:=",", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Cindy Meister
  • 25,071
  • 21
  • 34
  • 43

2 Answers2

0

You can still use range, but generate it dynamically: use the macro recorder and see what it gives you if you select all cells with the Select All button at the top left corner, then hold down CTRL and unselect by clicking the row headers.
After having a selected range, you can use Application.Selection instead of Cells.

Dávid Laczkó
  • 1,091
  • 2
  • 6
  • 25
0
set wsCSV = ... (your csv worksheet)
set rng = wsCSV.UsedRange
set ws = ... (your worksheet)
ws.UsedRange.Offset(1).ClearContents()
ws.Range("A2").Resize(rng.Rows.Count, rng.Columns.Count).Values = rng.Values
Alpha
  • 2,372
  • 3
  • 21
  • 23