In the Invoice Data2 sheet there are cells highlighted yellow that I would like to have posted to the Database Table A:K starting in row 17 like in my example please. Can one button post this data and clear for new or should there be 2 buttons?
In my opinion, both ranges are the same, so all you need is one button.
New data will be written when you use Button 'Add'.
Assign my code to the 'Add' button.
The REF column is not matching the numbers for data and would it be possible to not have the blank rows? The 6, 7, 8, 9 don't have data but are copied.
Can one button post this data and clear for new or should there be 2 buttons?
One button is enough so according to your attachment a starter demonstration
to paste to the Invoice Data2 worksheet module :
PHP Code:
Sub Demo1() Dim R& R = [H3:K13].Find("*", , xlValues, , xlByRows, xlPrevious).Row - 3 If R Then With [A16].ListObject.Range.Columns(1).Find("*", , , , , xlPrevious)(2) .Resize(R, 6).Value = [A4:F4].Value2 .Offset(, 6).Resize(R, 5).Value2 = [G4:K4].Resize(R).Value2 End With [A4:F4,H4:K13].ClearContents End If End Sub
Do you like it ? So thanks to click on bottom left star icon « ★ Add Reputation » !
Last edited by Marc L; 08-23-2019 at 09:49 PM.
Reason: optimization …
I tried your code but I have requests please. I did some adjustments of the sheet and there are also formulas that I would like to stay so I changed the Clear Contents part of the code.
I have an issue now if I only enter one line item (service or material) it doesn't post the data or clear the area. Also if I have more that one item let's say 4 only 3 line items are posted.
Your bad : delete Module1 then this time well read & apply the dark red direction just before the code !
And amend the ClearContents codeline for the ranges to clear …
Thank you Maras for the edited code to fit my new layout. I opted to use the code from Marc L it seems less complicated. I hope you can understand my choice.
Bookmarks