pass contents of textbox to save rootine

EDUCATED MONKEY

Board Regular
Joined
Jul 17, 2011
Messages
218
My set up is office 2007 win xp pro ie 8
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p> </o:p>
The desired effect is to take the input from the hand barcode reader and save the results automatically.
The current method is as follows select the starting point on the spreadsheet, let’s say a completely new sheet so i select A1, scan the barcode numbers appear in A1 as expected the i press done one on the keyboard scan next barcode.
What i have achieved so far is create user form and called it DataInPut, with textbox on it, the form is activated by a command button on a spreadsheet called Start Up the button its self being called BtnStart and has the caption Get Data, the text box on the user form i have called TextBoxIsbn
Rich (BB code):
Rich (BB code):
Rich (BB code):
Private Sub TextBoxIsbn_Change()
If Len(TextBoxIsbn.Value) = 13 Then
       Module11.SaveData          
End If
End Sub

Module11 code
Rich (BB code):
Rich (BB code):
Rich (BB code):
Sub SaveData()
Dim MyData As Variant
Dim lr As Long
MyData = DataInPut.TextBoxIsbn.Value
Worksheets("ISBN INPUT").Select
lr = Cells(Rows.Count, 1).End(xlUp).row + 1 ' looks in Col A
Cells(lr, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
Application.CutCopyMode = False
End Sub

The problem seems to that i do not know how to pass the data from the textbox to the pastspecial rootine
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
EDUCATED MONKEY,

Perhaps try this....

Pass MyData in the call to SaveData.


Code:
Private Sub TectBoxIsbn_Change ()
If Len(TextBoxIsbn.Value) = 13 Then
MyData = TextBoxIsbn.Value
Module11.SaveData(Mydata)
End If
End  Sub

Also forget paste. Just assign data to cell value.

Code:
Sub SaveData(MyData As Variant)
Dim lr As Long
Worksheets("ISBN INPUT").Select
lr = Cells(Rows.Count, 1).End(xlUp).Row + 1 ' looks in Col A
Cells(lr, 1).NumberFormat = "@"
Cells(lr, 1).Value = MyData
End Sub

Hope that helps.
 
Upvote 0
HI Tony thanks I am up and running with this all I added to your code was a method to clear the text box, looking at the code I see that you pass data in the bracket as you do in other languages like C++<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p> </o:p>
Here is your code with the minor change <o:p></o:p>
<o:p> </o:p>
Rich (BB code):
<o:p></o:p>
Rich (BB code):
Rich (BB code):
<o:p> </o:p>
Sub SaveData(MyData As Variant)
Dim lr As Long
Worksheets("ISBN INPUT").Select
lr = Cells(Rows.Count, 1).End(xlUp).Row + 1 ' looks in Col A
Cells(lr, 1).NumberFormat = "@"
Cells(lr, 1).Value = MyData
DataInPut.TextBoxIsbn.Value = ""
End Sub
<o:p></o:p>
<o:p> </o:p>
Thanks again works perfectly
 
Upvote 0

Forum statistics

Threads
1,215,328
Messages
6,124,299
Members
449,149
Latest member
mwdbActuary

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