I'm analyzing some light spectra and am trying to select the intensity readings correspondent to certain wavelength, and paste them in a new worksheet. The code does run, however it presents a
Run-time error '1004' - Application-defined or object-defined error on the Worksheets(2).Cells(i, "B").Value = Worksheets(1).Cells(greenwl, columnnumber).Value code line
Sub GreenWlValues()
Dim targetwl As Long
Dim greenwl As Long
Dim columnnumber As Long
Dim i As Long 'used to denote the cell rows in the new Worksheet
targetwl = 9 'example value
columnnumber = 2
i = 2
For greenwl = 1 To Cells(Rows.Count, 1).End(xlUp).Row
Do While Cells(greenwl, "A").Value = targetwl
Worksheets(2).Cells(i, "B").Value = Worksheets(1).Cells(greenwl,
columnnumber).Value
columnnumber = columnnumber + 1
i = i + 1
Loop
Next greenwl
End Sub
columnnumber
. You are also probably looping in wrong bounds due to the unqualifiedCells
calls. – GSerg