Select a single line even if there are merged cells with VBA

[Closed]
Report
-
Posts
2806
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
September 20, 2021
-
Hello,

I'm creating a worksheets that needs to be protected at all time. However, users may need to duplicate a line sometimes. What I want to do here is to make them choose a location where to insert a new line - by selecting this line, the code copies the line above (containing formulas) and insets it below the selected line.

I'm able to unprotect the sheet and make appear the input.box and etc, however, most of the cells in row B are merged with other cells above or below in that same row. So far, application.inputbox allows me to select a line, but if that line has some merged cells with others lines, the application selects all the lines connected by this cell containing merged cells in row B and therefore I've selected many lines.

Do you know how to select a single line regardless if it has merged cells or not in row B and then copy it with VBA ? Is application.inputbox the right way to do it?

Greatly appreciated!

Jerry

1 reply

Posts
2806
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
September 20, 2021
482
Hi Jerry,

Merged cells don't work well with VBA. You will have to start your code by unmerging first then finish the code by merging the cells again.

Best regards,
Trowa