0

I am searching a way to put some information into an Excel Worksheet:
I want to put what's in a ComboBox in Column A Row1 Multiline Textbox in Column A Row2 (if possible every line of the TextBox in a different line of the column) and another specific "Text" in next available line after the infos of the TextBox

I already have a Code that populates the Cells in Sheet 1, and I want it to do this to Sheet2. Then, I Clear the fields, start new infos and do the same to the next available column.

What I want it to do:
What i want it to do

Userform looks like:
Userform looks like

What it already does:
What it already does

'add infos to sheet1
Feuil1.Activate
Feuil1.Select

lastrow = Cells(Rows.Count, 1).End(xlUp).Row
Cells(lastrow, 1).Offset(1, 0).Select


emptyrow = WorksheetFunction.CountA(Range("A:A")) + 1
       
Cells(emptyrow, 1).Value = MonthView1.Value
Cells(emptyrow, 2).Value = MonthView1.Value
Cells(emptyrow, 3).Value = ServiceBox.Value
sn = Split(RecomBox.Text, vbLf)
Cells(emptyrow, 4).Resize(, UBound(sn) + 1) = sn

Columns("B:B").Select
    Selection.NumberFormat = "dd/mm/yyyy;@"
Columns("A:A").Select
    Selection.NumberFormat = "mmmm yyyy;@"

'add infos to sheet2
Feuil2.Activate
Feuil2.Select
ZygD
  • 22,092
  • 39
  • 79
  • 102
  • Hi, please *Do Not* post your code as an image, post is as a text instead. [Here is why you should not post your code as an image](https://meta.stackoverflow.com/a/285557/15366635) – I_love_vegetables Aug 17 '21 at 05:51
  • I edit my post to show my code. Hope it helps to get help – Bruno Pereira Aug 17 '21 at 06:00
  • awesome, goodluck :D – I_love_vegetables Aug 17 '21 at 06:02
  • What's the issue are you having trying to populate the data into Sheet2? (Btw this looks like something you can try using Pivot Table...) Note: Not an answer to your question but you are highly recommended to read on [How to avoid using Select](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba?rq=1). – Raymond Wu Aug 17 '21 at 07:18
  • Everytime i click on the Commandbutton to add the infos from the ComboBox and the TextBox to sheet2, i want that it jumps to the next column. – Bruno Pereira Aug 17 '21 at 07:22
  • [This answer](https://stackoverflow.com/questions/38882321/better-way-to-find-last-used-row) will help you to get the last column in a row so you just need to + 1 (just like how you do for `emptyrow`, you are also recommended to find the last row from the same answer as well instead of your current method (`emptyrow = WorksheetFunction.CountA(Range("A:A")) + 1`) @BrunoPereira – Raymond Wu Aug 17 '21 at 07:24

0 Answers0