Problems when i add new rows in table via userform. Formulas wont get taken over and cell formats are changing

Xalova

Board Regular
Joined
Feb 11, 2021
Messages
80
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
So i have this table here:

Bewerbungsliste.xlsm
DEFGHIJKL
4#BewerbungslisteOrtDatumPortalStatusLetztes UpdateTage seit BewerbungKommentar
51Roland Deeg GmbHKirchberg an der Jagst23.10.2023Bewerbung per HomepageAbsage22.11.202338Die Bewerbung ist 38 Tage her
62JMS AG Jet Maintenance & ServiceLahr23.10.2023StepStoneWarte auf Antwort14.11.202338Wohl wahrschneinlich Absage. Teams Gespräch verpasst
73BIEBER + MARBURG GMBH + CO KGGießen24.10.2023StepStoneWarte auf Antwort37Mehr als 3 wochen her. Unwahrscheinliche Antwort
84Hermann Linden Maschinenfabrik GmbH & Co. KGMarienheide24.10.2023StepStoneWarte auf Antwort37Mehr als 3 wochen her. Unwahrscheinliche Antwort
95FBI Personallösungen GmbHHamburg25.10.2023Bewerbung per TelefonBewerbungsgespräch24.11.202336VG in Hemmingstedt bei Schäffer Group
106RHEINMETALL AGBonn30.10.2023Bewerbung per HomepageAbsage31 
117POOLgroup GmbHEmsdetten30.10.2023StepStoneWarte auf Antwort31Mehr als 3 wochen her. Unwahrscheinliche Antwort
128Pfeiffer Vacuum GmbHKempen31.10.2023StepStoneAbsage30 
139PFLITSCH GmbH & Co. KGKerpen31.10.2023StepStoneWarte auf Antwort30Mehr als 3 wochen her. Unwahrscheinliche Antwort
1410ENGIE Deutschland GmbHKöln31.10.2023Direktbewerbung (E-Mail)Warte auf Antwort30Mehr als 3 wochen her. Unwahrscheinliche Antwort
1511Hansa Industrie-Mixer GmbH & Co.KGStuhr31.10.2023StepStoneWarte auf Antwort30Mehr als 3 wochen her. Unwahrscheinliche Antwort
1612HAPEKO Hanseatisches Personalkontor Deutschland GmbHHerford06.11.2023StepStoneAbsage24 
1713Brunel Service GmbH & Co. KGRostock06.11.2023Get-in-EngineeringWarte auf Antwort24Mehr als 3 wochen her. Unwahrscheinliche Antwort
1814benntec Systemtechnik GmbHBremen07.11.2023StepStoneAbsage23 
1915FERCHAU GmbHHamburg07.11.2023Bewerbung per HomepageWarte auf Antwort23Mehr als 3 wochen her. Unwahrscheinliche Antwort
2016Bohlen & Doyen Bau GmbHWiesmoor07.11.2023StepStoneWarte auf Antwort23Mehr als 3 wochen her. Unwahrscheinliche Antwort
2117ENGIE Deutschland GmbHKöln14.11.2023StepStoneAbsage16 
2218LAKAL GmbHSaarlouis14.11.2023Bewerbung per HomepageWarte auf Antwort16 
2319NORD Engineering Müller GmbHHamburg14.11.2023Bewerbung per HomepageAbsage23.11.202316 
2420Kirchgässner Elektrotechnik GmbHBinau22.11.2023StepStoneWarte auf Antwort8 
2521WETROPA Kunststoffverarbeitung GmbH & Co. KGMörfelden-Walldorf22.11.2023Bewerbung per HomepageWarte auf Antwort8 
2622Minimax GmbHHermsdorf27.11.2023StepStoneWarte auf Antwort3 
2723Franken Apparatebau GmbHOberhausen27.11.2023StepStoneWarte auf Antwort3 
2824Euroroll GmbHWerne27.11.2023StepStoneWarte auf Antwort3 
2925Röhrenwerk Kupferdreh Carl Hamm GmbHEssen27.11.2023StepStoneWarte auf Antwort3 
3026ORANGE EngineeringHannover27.11.2023StepStoneWarte auf Antwort3 
Tabelle1
Cell Formulas
RangeFormula
L5L5="Die Bewerbung ist "&DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY()))-G5&" Tage her"
L7:L8,L10:L30L7=IF(AND([@Status]<>"Zusage",[@Status]<>"Absage",[@[Tage seit Bewerbung]]>21),"Mehr als 3 wochen her. Unwahrscheinliche Antwort","")
K5:K30K5=DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY()))-G5
D5:D30D5=ROW()-ROW(Bewerbungsliste[#Headers])


which is just a simple application list for me. I wanted to create a userform which makes it a lil easier for me to populate a new row.


the problem colums im talking about are "Datum", "Letztes Update", "Tage seit bewerbung" and "Kommentar".


What i wanted to achieve is that when my textbox for the colum "Datum" is empty, then it should add the date of today and if the textbox for "letztes update" is empty then it should leave the cell empty. The row "Tage seit Bewerbung" is just overall a bit ****y and i dont even know what to do here. Also the Column "Kommentar" just doesnt take over the existing formula.

thats how my last row looks like when i enter an empty userform:
Bewerbungsliste.xlsm
DEFGHIJKL
3127#########StepStone12:00:00 AM30.11.2023
Tabelle1
Cell Formulas
RangeFormula
D31D31=ROW()-ROW(Bewerbungsliste[#Headers])
K31K31=DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY()))-G31


here is the the code for entering the values from the userform:
VBA Code:
Private Sub EnterExit_Click()

Dim Firma As String
Dim Ort As String
Dim dtBewerbung As Date
Dim Status As String
Dim dtLetztesUpdate As Date
Dim Kommentar As String

If Me.dtBewerbung = "" Then
Me.dtBewerbung = Date
End If

If Me.Status = "" Then
Me.Status = "warte auf Antwort"
End If


Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets(1)
Dim tbl As ListObject
Set tbl = ws.ListObjects("Bewerbungsliste")
Set lrow = tbl.ListRows.Add
With lrow

.Range(2) = Firma
.Range(3) = Ort
.Range(4) = dtBewerbung
If Me.optBewerbungHomepage.Value Then .Range(5) = "Bewerbung per Homepage"
If Me.optBewerbungTelefon.Value Then .Range(5) = "Bewerbung per Telefon"
If Me.optDirekt.Value Then .Range(5) = "Direktbewerbung (E-Mail)"
If Me.optGetInEngineering.Value Then .Range(5) = "Get-In-Engineering"
If Me.optIndeed.Value Then .Range(5) = "Indeed"
If Me.optLinkedIn.Value Then .Range(5) = "LinkedIn"
If Me.optStepStone.Value Then .Range(5) = "StepStone"
If Me.optXing.Value Then .Range(5) = "Xing"
.Range(6) = Status
.Range(7) = dtLetztesUpdate
.Range(9) = Kommentar

End With
'Me.Hide
End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Do you have one of the TextBoxes in your userform named dtBewerbung and a variable with the same name? If "Yes" then be aware that the textbox doesn't magically export its content to the variable.
So somewhere you need to execute a dtBewerbung = cDate(Me.dtBewerbung.Value) for having the variable populated.
Of course I think is quite error prone assigning objects (eg a textbox) the same name of a variable; and probably there is even not the need for exporting the textbox value to a variable and then assign the variable to a cell: I mean you can directly assign the textbox value (using a conversion function, eg cDate to convert a "text" to a "Date") to a cell.

I don't see how you set the value for variables Firma, Ort, Status and other, so I suspect that you have textboxes with these same names and you expect that their values magically move to the variable, that is not the way the userform works.

I hope you understand what I mean and revise your project to:
-use variables names that are different from the name of the controls (recommanded)
-add the instructions to move the values of the controls to the variables, or move directly the values from the controls to the table cells

Bye
 
Upvote 0
Do you have one of the TextBoxes in your userform named dtBewerbung and a variable with the same name? If "Yes" then be aware that the textbox doesn't magically export its content to the variable.
So somewhere you need to execute a dtBewerbung = cDate(Me.dtBewerbung.Value) for having the variable populated.
Of course I think is quite error prone assigning objects (eg a textbox) the same name of a variable; and probably there is even not the need for exporting the textbox value to a variable and then assign the variable to a cell: I mean you can directly assign the textbox value (using a conversion function, eg cDate to convert a "text" to a "Date") to a cell.

I don't see how you set the value for variables Firma, Ort, Status and other, so I suspect that you have textboxes with these same names and you expect that their values magically move to the variable, that is not the way the userform works.

I hope you understand what I mean and revise your project to:
-use variables names that are different from the name of the controls (recommanded)
-add the instructions to move the values of the controls to the variables, or move directly the values from the controls to the table cells

Bye
no,i dont have a variable with the same name as a textbox. But what might make you think that this is the case is that i thought that i had to dim the values from the textboxes too...? please correct me here if i am wrong.

otherwise i handled the problem by manually re-formatting the cells that are getting formated with code. not the prettiest solution, but it works
 
Upvote 0
no,i dont have a variable with the same name as a textbox
I'm sorry but I have to disagree:
-When you write Dim dtBewerbung As Date you are declaring a vba variable whose name=dtBewerbung and type=Date
-When you write Me.dtBewerbung, aren't you referring to a TextBox (this is my best guess) whose name=dtBewerbung?
So it seem that YOU DO HAVE a variable and a textbox having the same name

i thought that i had to dim the values from the textboxes too
A "textbox" returns a string, you cannot change that nor you can "dim" it
Again, insisting on the previous point, the instruction Dim dtBewerbung declares a vba "variable", and doesn't affect the textbox that is named "dtBewerbung"

Similarly, when you write Dim Firma As String you are declaring a vba variable; then you never assing a value to that variable, so the instruction .Range(2) = Firma will put an empty string into ".Range(2)". My best guess for that strange situation is that you have a textbox named "Firma" and you assume that the content of this textbox magically moves into the variable with the same name; but that is wrong: you have to move the content of the textbox to the variable, then can move the variable to ".Range(2)"; or you can move directly the content of the textbox directly to the cell (for example: .Range(2) = Me.Firma.Value)

This situation happens for several variables, and I guess that for each of those variables there is a textbox having the same name

You can review the names of the controls on the userform by displaying (within the Vba editor) the userform, then selecting each control and inspecting the "Property box" (that shows not only the Name but the other properties that you can manage)
 
Last edited:
Upvote 0
Solution
I'm sorry but I have to disagree:
-When you write Dim dtBewerbung As Date you are declaring a vba variable whose name=dtBewerbung and type=Date
-When you write Me.dtBewerbung, aren't you referring to a TextBox (this is my best guess) whose name=dtBewerbung?
So it seem that YOU DO HAVE a variable and a textbox having the same name


A "textbox" returns a string, you cannot change that nor you can "dim" it
Again, insisting on the previous point, the instruction Dim dtBewerbung declares a vba "variable", and doesn't affect the textbox that is named "dtBewerbung"

Similarly, when you write Dim Firma As String you are declaring a vba variable; then you never assing a value to that variable, so the instruction .Range(2) = Firma will put an empty string into ".Range(2)". My best guess for that strange situation is that you have a textbox named "Firma" and you assume that the content of this textbox magically moves into the variable with the same name; but that is wrong: you have to move the content of the textbox to the variable, then can move the variable to ".Range(2)"; or you can move directly the content of the textbox directly to the cell (for example: .Range(2) = Me.Firma.Value)

This situation happens for several variables, and I guess that for each of those variables there is a textbox having the same name

You can review the names of the controls on the userform by displaying (within the Vba editor) the userform, then selecting each control and inspecting the "Property box" (that shows not only the Name but the other properties that you can manage)
Wow, didnt know that. Thank you for making it clear for me!

I have removed the "dim's" and now it works as if nothing happened (i commented out the formatting in the code). Thank you for helping me :)
 
Upvote 0
I have removed the "dim's" and now it works as if nothing happened
:unsure:
Does it work correctly or "nothing happens" [when you press EnterExit]?
If "nothing happens" then publish the code for Sub EnterExit_Click
 
Upvote 0
:unsure:
Does it work correctly or "nothing happens" [when you press EnterExit]?
If "nothing happens" then publish the code for Sub EnterExit_Click
sorry for the misunderstanding.

It does work perfectly fine now and does exactly what i wished it to do :)

thank you a bunch again 😁
 
Upvote 0
Thank you for the feedback
If the problem is solved then it'd be better to mark the discussion as Resoved; see the procedure: Mark as Solution
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,963
Members
449,094
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top