danter1972
New Member
- Joined
- Aug 27, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
in a sheet I have column A with merged rows in groups of 7 rows
Using VBA I want to find either:
- if the ID is already present a row: return the row number where the value is found
- if the ID doesn't exist: return the row number of the first free cell
I was using this code in another sheet without merged rows and worked fine but I cannot adapt it to function with presence of merged rows, always returns SM_lastrow=9 and (obviously) SM_emptyrow=16
If Not IsError(Application.Match(ID, Range("a2:a90000"))) Then 'CHECK IF A RECORD WITH ID EXIST IN THE SHEET
SM_matchrow = Sheets("TEST").Range("A:A").Find(what:=ID, LookIn:=xlValues, lookat:=xlWhole).Row
SM_emptyrow = SM_matchrow
Else
SM_lastrow = Sheets("shipping monitor").Range("a2").End(xlDown).Row 'find last row in the column A of the sheet
SM_emptyrow = SM_lastrow + 7 'sheet has merged rows in groups of 7
End If
Thank you in advance for the support
Using VBA I want to find either:
- if the ID is already present a row: return the row number where the value is found
- if the ID doesn't exist: return the row number of the first free cell
I was using this code in another sheet without merged rows and worked fine but I cannot adapt it to function with presence of merged rows, always returns SM_lastrow=9 and (obviously) SM_emptyrow=16
If Not IsError(Application.Match(ID, Range("a2:a90000"))) Then 'CHECK IF A RECORD WITH ID EXIST IN THE SHEET
SM_matchrow = Sheets("TEST").Range("A:A").Find(what:=ID, LookIn:=xlValues, lookat:=xlWhole).Row
SM_emptyrow = SM_matchrow
Else
SM_lastrow = Sheets("shipping monitor").Range("a2").End(xlDown).Row 'find last row in the column A of the sheet
SM_emptyrow = SM_lastrow + 7 'sheet has merged rows in groups of 7
End If
Thank you in advance for the support