Yes, it is the format dd/mm/yyyy i want to use, and it seems like that format in the worksheet, but excel doesnt recognize it as date, but text, and therefore it sorts wrongly. The april line stays at the top, and latest dates seems to place randomly. I have tried to change format both in worksheet and vba, but cant get it right.
Thanks, the list headers is a good solution for keeping the headers in listbox.
About date, and sorting, it seems like it dont get a date-format, and so the sorting dont get right.
Thanks Roy for going through all my vbas. The change button works properly now. Nice!
But there came two new problems, perhaps you have a solution for that too?
1: The listbox in form do not have headings longer.
2: But more importenly, I want the newest entries to be first/at the top in the table/listbox, (because newest will be most relevant for users to look at).
...more precise; it only changes the "user name", not other contents when I try change that.
When i change an entry in database ("change" button in form), it only change one cell in the row.
Thanks. I tried to edit my post to fix the Code, but cant find where to start editing my recent post.
The sheet with this code, have several ranges with different headlines, so it is unfortunately not suitable for a Table.
I'm trying to use a vba to insert a row, and copy dynamic formulas from above.
I have problem with formulas like "=SUM($F$9:F12)". The new row get the same formula, but should get "=SUM($F$9:F13)".
My vba code is like this:
' Q4 is input to define which row to insert new.
Dim verdi As Variant
verdi = Range("Q4").Value
' Copy formula from cell above
Rows(Selection.Row - 1).Copy
It works perfectly. Just as desired. Thank you very much for your solution.
Ok, I will do some more research about that. But thank you so much royUK for your time and help. Your code is very helpfull. I will study it more and try to find a way to paste it ether as picture or make it work as it is. The code in my first post did save the range as pictures, so it should be possible.
But again, I am grateful for your commitment to help me.
Wow, that code does work for several ranges! Thanks for the help so far.
To keep the format of the ranges, and to prevent any unauthorized changes to numbers, I would prefer it to be pasted as pictures to word.
I tried to change the code, but it was not as easy as I had hoped. Maybe it is for you?
I guess we have to Select all the ranges and then copy all at once?
Thank you for the superquick reply
Sorry, I did not see the "display more" function at first.
Now I tried your code, got an error. Please see the picture. Here I also illustrate how the workbook should work.
Thank you for your reply.
I have a workbook template with closing accounts. Each month, several areas of this workbook will be copied into Word for presentation and printing.
To make copying more efficient, I want a VBA that copies the areas by the touch of a button. It should be possible for my colleagues to edit the areas to be copied, even if they have no knowledge of VBA. Therefore, I want the VBA to copy areas based on the values in the cells F3:F20. I do not know if it is best to define an area name or location (for example sheet1! B2: G10) in the F coloumn.
The code I have written will copy the named range valued in F3, and paste it as a picture in a new word document.
I want to copy several ranges in a workbook to one Word document. How do I do that with a VBA?
In this example, I have defined the ranges with names. In "sheet3", I want range F3:F20 to be cells that users can type in which name ranges they want to export to Word.
This code does work if the named range is in the same sheet as the button. But I need it to work when the named ranges are in another sheets.
I also need this code to copy next named range valued in the F3 cell, and down to end of list.
I appreciate your helpCode
- Private Sub CommandButton3_Click()
- Dim WordApp As Word.Application
- Dim WordDoc As Word.Document
- Set WordApp = New Word.Application
- Set WordDoc = WordApp.Documents.Add
- Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
- WordApp.Visible = True
- Set objSelection = WordApp.Selection
- End Sub