always_confused
Board Regular
- Joined
- Feb 19, 2021
- Messages
- 68
- Office Version
- 2016
- Platform
- Windows
Hello,
I have two sheets: one with raw data, and one where I'd like to do some analysis. In Sheets("raw_data").Range("W:W") I have measured values. I would like to copy only the non 0 values to Sheets("analysis").Range("A:A") .
The way I'm doing it now is:
I would just like to know if there's a faster way of doing this, because my raw_data file is quite long....
I have two sheets: one with raw data, and one where I'd like to do some analysis. In Sheets("raw_data").Range("W:W") I have measured values. I would like to copy only the non 0 values to Sheets("analysis").Range("A:A") .
The way I'm doing it now is:
VBA Code:
Sub copy_data()
Dim lastrow As Long
lastrow = Sheets("raw_data").Range("W" & Rows.Count).End(xlUp).Row 'gets number of rows in raw_data
For i = 2 To lastrow 'copies non null values into A
If Sheets("raw_data").Range("W" & i).Value <>0 Then
Sheets("analysis").Range("A"&Rows.Count).End(xlUp).Row.Offset(1,0).Value = Sheets("raw_data").Range("W" & i).Value
End If
Next i
End Sub
I would just like to know if there's a faster way of doing this, because my raw_data file is quite long....