Need help about vba code for User form in sheet

maiwarits

New Member
Joined
Jul 17, 2022
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Hi guys,

I tried to create user form for my report in excel sheet not a user form in VBA code.
I try many code on the internet but it not match my expect.

Please see the detail below, and suggest me for the code.

This user form in the sheet name "EnterIn" the value is actually in the column B but I use center across selection.
B3= 11-Jan-2023
B4= CYL-004
B5= Operation gas
B6= Pure Oxygen (O2) 99.9995% min
B7= 5
B8= 20000

Value in B3-B8 will place in destination sheet base on header.
1673420231601.png


This sheet is the destination sheet with "InHistory" name.
1673422018188.png


Explanation:
After entry the data in B3-B8 then click SUBMIT button the data should go in to the destination sheet then clear the value in B3-B8.
The value should go only the value not a formular in cell.

This my starter code:
VBA Code:
Public Sub EnterIn()
    Dim wsEnterIN As Worksheet 'define source sheet
    Set wsEnterIN = ThisWorkbook.Worksheets("EnterIn")

    Dim wsInHistory As Worksheet 'define destination sheet
    Set wsInHistory = ThisWorkbook.Worksheets("InHistory")

    Dim DestRow As Long
    DestRow = 6 'start in row 2 in destination sheet







End Sub

Thanks,
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
I hope this works:
VBA Code:
Sub Submit_Click()
  With Worksheets("InHistory")
  Worksheets("EnterIN").Range("B3:B8").Copy
  .Cells(.Cells(Rows.Count, 2).End(xlUp).Row + 1, 2).PasteSpecial Paste:=xlPasteValues, Transpose:=True
  Worksheets("EnterIN").Range("B3:B8").Value = ""
  End With
End Sub
 
Upvote 0
I hope this works:
VBA Code:
Sub Submit_Click()
  With Worksheets("InHistory")
  Worksheets("EnterIN").Range("B3:B8").Copy
  .Cells(.Cells(Rows.Count, 2).End(xlUp).Row + 1, 2).PasteSpecial Paste:=xlPasteValues, Transpose:=True
  Worksheets("EnterIN").Range("B3:B8").Value = ""
  End With
End Sub
The code clears my formula in the cell also. Is it possible to don't clear the formula in the cell?
 
Upvote 0
If there is formula in cells, howcome do you expect that it won't display any results?
 
Upvote 0
If there is formula in cells, howcome do you expect that it won't display any results?
Sorry for unclear explanation.

The value in gray box (B3, B4, B5, B8) have formular they will show after B6 entry any value.

So, it should clear the data in cell B6,B7 only after click submit button.
but B3:B7 it should copy only the value not a formular to destination sheet.

Btw, Many Thanks for your kind helpful!
 
Upvote 0
Change this line:
VBA Code:
Worksheets("EnterIN").Range("B3:B8").Value = ""

To this:
VBA Code:
Worksheets("EnterIN").Range("B6:B7").Value = ""
 
Upvote 0
Change this line:
VBA Code:
Worksheets("EnterIN").Range("B3:B8").Value = ""

To this:
VBA Code:
Worksheets("EnterIN").Range("B6:B7").Value = ""
Hi, Sorry for late reply

Many Thanks for your help!
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,873
Members
449,056
Latest member
ruhulaminappu

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