What I want to do is pretty simple, I just have literally 0 experience with VBA. I have experience coding in other languages though (java, js, c, etc.).
What I am trying to do is go through the rows of an excel sheet, see if the integer value in the first cell of each row is within a certain range, and if it is, then copy that entire row and paste it into a new sheet that will be saved as a CSV.
I am able to go through the column and check the first cell value in each row, I now need to know how to take that corresponding row, copy it, and paste it in the CSV sheet.
For example, say this is the excel sheet I am trying to parse:
Say the user specifies that they want to grab all rows where the value in the first cell of that row is between 3 and 9 (rows 6-8, 11, 13-15). My VBA code would then go through all the rows and grab only the rows that fit the criteria above, and then send those rows to a new sheet that would look something like this:
This is what my code looks like right now, which goes down Column A, and checks the value in first cell of each row. I am not sure how to grab each row, and then send it to the new sheet
Sub exportDesiredRowsToCSVSheet()
Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = "myCSV"
MsgBox "Sheet 'myCSV' was created" 'create new sheet that I will save as CSV at the end
firstL = Application.InputBox("first line item num", "please enter num", , , , , , 1) 'gets user to input lower bound
lastL = Application.InputBox("last line item num", "please enter num", , , , , , 1) 'gets user to input upper bound
For Each Row In Range("A:A") 'go through rows in column A
For Each Cell In Row 'go through first cell in each row of column A
If Cell.Value >= firstL And Cell.Value <= lastL Then 'if the value in the cell is in the range
'Here I want to take the desired rows and copy/paste them to a the newly created 'myCSV' sheet
End If
Next
Next
End Sub
Any help is appreciated!