title: Fast Way to Normalize Data with VBA (Excel)
body: <p>I'm currently trying to normalize data with VBA in Excel. Therefore, my workbook imports several csv files and wrote them in different worksheets all of them are built like this.</p>
  
  <ul>
  <li>First row: Header</li>
  <li>First column: x-Axis (for plotting)</li>
  <li>Second column to nth column: y-values</li>
  </ul>
  
  <p>Now I want to normalize all columns from 2 to n (dividing by maximum value of each column). Here is the function I'm using so far:</p>
  
  <pre><code>Sub NormalizeData(dataName)
  
  cs = Worksheets(dataName).UsedRange.SpecialCells(xlCellTypeLastCell).Column
  rs = Worksheets(dataName).UsedRange.SpecialCells(xlCellTypeLastCell).Row
  
  For col = 2 To cs
      maxValue = Application.WorksheetFunction.Max(Worksheets(dataName).Columns(col))
  
      For r = 2 To rs
          Worksheets(dataName).Cells(r, col) = Worksheets(dataName).Cells(r, col) / maxValue
      Next r
  Next col 
  End Sub
  </code></pre>
  
  <p>This approach works, but because of the amount of data, it's very slow. Is there any way to increase the speed? I already switched of the screen update.</p>
  
  <p>Thanks you very much for your help!!!</p>