code doesn't work using userform but just work inside the sheet

Mussa

Board Regular
Joined
Jul 12, 2021
Messages
240
Office Version
  1. 2019
  2. 2010
Hi guys
this code should work when I copy data from userform to sheet
when copy data from userform to sheet and fill column B should populate date in column A and should populate calculation in column H= column F* column G, but doesn't work totally , just when I write the values inside the cell from inside the sheet will be work !
can any body help please?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If Intersect(Target, [B:B]) Is Nothing Or Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, [B:B]) Is Nothing Then
    Target.Offset(, -1) = Date
   Range("H2", Range("F" & Rows.Count).End(xlUp).Offset(, 2)).Formula = "=F2*G2"
   Range("H2", Range("F" & Rows.Count).End(xlUp).Offset(, 2)).Value = Range("H2", Range("F" & Rows.Count).End(xlUp).Offset(, 2)).Value
  End If
End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Could you maybe provide some sample data via XL2BB?
 
Upvote 0
Hi,
I'm not sure why you want data ?
any way here is the data should be after copy data from userform to sheet . as I said the problem in column A(DATE), , column H (calculation between columns F,G)
v04 a.xlsm
ABCDEFGH
1DATECODEBRANDBATCHDEL NQTYPRICEAMOUNT
226/04/2023CCS-001CTR-001BTR-001CDF-00200.0010.002,000.00
326/04/2023CCS-002CTR-002BTR-002CDF-01200.0010.002,000.00
426/04/2023CCS-003CTR-003BTR-003CDF-02200.0010.002,000.00
526/04/2023CCS-004CTR-004BTR-004CDF-03200.0010.002,000.00
BRANDS
 
Upvote 0
I am of the thought that you might need to write this code into the userform code itself when sending to the sheet.. I have taken the data and yes it does work on manual input but seeing as this is in a Worksheet Change event it will only work when you change the sheet manually... Might be wrong... I am just not sure what your userform code looks like to send the info to the sheet ..
 
Upvote 0
but I tested this procedure with another tab for multipage surprisingly works !
I no know why this tab doesn't work with this sheet .:unsure:
the code is
VBA Code:
Private Sub CommandButton1_Click()
 
Dim i As Long, j As Long
Dim LstRw As Long, CurrCon As String, ws As Worksheet
Dim va, a As Long, b As Long, h As Long

Set ws = sheet2
'find last used row
LstRw = ws.Range("B" & Rows.Count).End(xlUp).Row

    h = 11 * 7    'columns count on userform are 7,rows are 11
    a = 1
    ReDim va(1 To 11, 1 To 7)

    For i = 1 To h 'loop userform textbox
          b = b + 1
            va(a, b) = Me.Controls("Textbox" & i + 65).Value   'textboxes number start at 66

              If b = 7 Then a = a + 1: b = 0
    Next i

ws.Range("B" & LstRw + 1).Resize(UBound(va, 1), UBound(va, 2)) = va
MsgBox "  ok"
Dim m, n As Long
For m = 66 To 145
For n = 99 To 101

Me.Controls("textbox" & m) = ""
Me.Controls("label" & n) = ""
Next
Next
End Sub
 
Upvote 0
Strange... Will have another look and advise
 
Upvote 0
Hello

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: why when copy data from user form don't change by using worksheet change event ?
There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,822
Members
449,096
Latest member
Erald

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