copy formula from cell to textbox

sachin katariya

New Member
Joined
Jul 13, 2020
Messages
21
Office Version
  1. 2013
Platform
  1. Windows
I have created a user form to update fees of students
problem is fees is paid in installment like =5000+5000 => 10000
but in text box it shows only value i.e 10000

How to copy formula from cell to textbox
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Private Sub CommandButton4_Click()
Dim x As Long
Dim y As Long
x = Sheets("data").Range("A" & Rows.Count).End(xlUp).Row
For y = 2 To x
If Sheets("data").Cells(y, 1).Text = TextBox22.Value Then
TextBox1.Text = Sheets("data").Cells(y, 5)
TextBox2.Text = Sheets("data").Cells(y, 7)
TextBox3.Text = Sheets("data").Cells(y, 8)......

This is to search student
 
Upvote 0
If you are happy with a simple function in VBA place the following code in a module within your workbook:
VBA Code:
Function GetFormula(cell As Range) As String
    GetFormula = cell.Formula
End Function
An example of how to use this:
If your formula of =5000+5000 is in cell A1 then you will now be able to use the formula =GetFormula(A1) in any other cell to show the formula itself rather than the result.

For users with Office 365 there is now a new formula called FORMUALTEXT that does the same thing without having to add your own VBA.
 
Upvote 0
Apologies - have just noted that you want to return this to a text box however by 'extracting' the text of the formula (as per my response) to another cell this should make it easier to show in a text box.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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