Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Is there any way to enter information into a specific cell in Excel using a variable. For example, if I had a textBox and wanted to move the information to cell Ax. where x is the integer variable, is there any way to do that ? -- SystemHack ------------------------------------------------------------------------ SystemHack's Profile: http://www.excelforum.com/member.php...o&userid=26614 View this thread: http://www.excelforum.com/showthread...hreadid=398944 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() do you do it in VBA? maybe this will help... Range("A" & x).Value = YourTextBox.Text or Cells(x, 1).Value = YourTextBox.Text :) SystemHack Wrote: Is there any way to enter information into a specific cell in Exce using a variable. For example, if I had a textBox and wanted to move the information t cell Ax. where x is the integer variable, is there any way to do that -- T-®e ----------------------------------------------------------------------- T-®ex's Profile: http://www.excelforum.com/member.php...fo&userid=2657 View this thread: http://www.excelforum.com/showthread.php?threadid=39894 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Ah exactly what I was looking for. Thank ! -- SystemHack ------------------------------------------------------------------------ SystemHack's Profile: http://www.excelforum.com/member.php...o&userid=26614 View this thread: http://www.excelforum.com/showthread...hreadid=398944 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Umm one more question, what is the string if the cell is in another sheet ? -- SystemHack ------------------------------------------------------------------------ SystemHack's Profile: http://www.excelforum.com/member.php...o&userid=26614 View this thread: http://www.excelforum.com/showthread...hreadid=398944 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Range("TheOtherSheet!A" & x).Value = TheValue syntax is: <NameOfSheet!<CellAddress Mind the *!* :) SystemHack Wrote: Umm one more question, what is the string if the cell is in anothe sheet -- T-®e ----------------------------------------------------------------------- T-®ex's Profile: http://www.excelforum.com/member.php...fo&userid=2657 View this thread: http://www.excelforum.com/showthread.php?threadid=39894 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() oi oi ... you have been a major help !! thanks bunches ! : -- SystemHac ----------------------------------------------------------------------- SystemHack's Profile: http://www.excelforum.com/member.php...fo&userid=2661 View this thread: http://www.excelforum.com/showthread.php?threadid=39894 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I tried all 3 methods below and get errors on each one. All I am tryin to do is when I click on the button, move the information from A,1 o Sheet 2 to the TextBox on Sheet 1. Any ideas what I am doing wrong ? TextBox1.Text = Range(Sheet2!A&1).Value TextBox1.Text = Range(Sheet2!A,1).Value TextBox1.Text = Range("Sheet2!A"&1).Valu -- SystemHac ----------------------------------------------------------------------- SystemHack's Profile: http://www.excelforum.com/member.php...fo&userid=2661 View this thread: http://www.excelforum.com/showthread.php?threadid=39894 |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
x = 1
worksheets("Sheet1").Textbox1.Text = Worksheets("Sheet2").Range("A" & x).Text to load the textbox. to put the textbox value in the cell x = 1 Worksheets("Sheet2").Range("A" & x).Value = worksheets("Sheet1").Textbox1.Text -- Regards, Tom Ogilvy "SystemHack" wrote in message ... I tried all 3 methods below and get errors on each one. All I am trying to do is when I click on the button, move the information from A,1 on Sheet 2 to the TextBox on Sheet 1. Any ideas what I am doing wrong ? TextBox1.Text = Range(Sheet2!A&1).Value TextBox1.Text = Range(Sheet2!A,1).Value TextBox1.Text = Range("Sheet2!A"&1).Value -- SystemHack ------------------------------------------------------------------------ SystemHack's Profile: http://www.excelforum.com/member.php...o&userid=26614 View this thread: http://www.excelforum.com/showthread...hreadid=398944 |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() hmm... actually "Range("Sheet2!A"&1).Value" works for me (so it's probably already correct) whether you're using it to read or write the value.... so the error must be in how you reference your textbox. what error message are you getting? are you using a textbox in a userform? if you are and the code below is located somewhere NOT in the user form, then you have to reference the textbox through its userform. YourUserForm.TextBox1.Text = Range("Sheet2!A"&1).Value try this... 1. Create a userform (name it MyUserForm) and put a textbox (name it MyTextBox) and a button (name it MyButton). (Be sure to set ShowModal property of MyUserForm to True - though it is set to True by default.) 2. Add an OnClick event handler to MyButton; MyUserForm should be hidden (NOT UNLOADED) when MyButton is clicked: Private Sub MyButton_Click() 'Just HIDE MyUserForm; don't unload Me.Hide 'To hide MyUserForm 'Experiment: Comment line of code above and uncomment below 'Unload Me End Sub 3. Add a button to any sheet in your workbook. Don't use Sheet2 if you're going to reference/use [Range("Sheet2!A"&1).Value]. 4. When you create the button in the sheet, the 'Assign Macro' dialog box should appear. Create a new macro for the button by clicking 'New'. This should take you to the VBA Editor, insided a subroutine (the OnClick event handler for the button - named something like Button1_Click). 5. Add code to the subroutine so it should look something like: Sub Button1_Click() MyUserForm.MyTextBox.Text = Range("Sheet2!A" & 1).Value MyUserForm.Show Range("Sheet2!A" & 1).Value = MyUserForm.MyTextBox.Text End Sub 6. Set the text in cell A1 in Sheet2 to any text you like. 7. Save (or don't save) your work... When you click on the button in the sheet, MyUserForm should appear. Notice the text in MyTextBox is the same as with the text in cell A1 in Sheet2. When you change the text in MyTextBox and click MyButton, the value in cell A1 in Sheet2 should be equal to the text you typed in MyTextBox. But, when you click the Close control button (the 'X' button) in MyUserForm, cell A1 in Sheet2 should now be empty. This is because MyUserForm has been unloaded. I know... the demo above is already a bit way-off... But, I hope it gave you some ideas... :) One more thing, if you're only concerned with referencing a cell value through a textbox, try using the 'ControlSource' property of the text box... If the demo doesn't work, contact me... ![]() SystemHack Wrote: I tried all 3 methods below and get errors on each one. All I am trying to do is when I click on the button, move the information from A,1 on Sheet 2 to the TextBox on Sheet 1. Any ideas what I am doing wrong ? TextBox1.Text = Range(Sheet2!A&1).Value TextBox1.Text = Range(Sheet2!A,1).Value TextBox1.Text = Range("Sheet2!A"&1).Value Now that I try it, I can't even get this to work on the same worksheet. -- T-®ex ------------------------------------------------------------------------ T-®ex's Profile: http://www.excelforum.com/member.php...o&userid=26572 View this thread: http://www.excelforum.com/showthread...hreadid=398944 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Searching for specific text - how to | Excel Worksheet Functions | |||
Searching in 'variable' worksheets | Excel Discussion (Misc queries) | |||
searching for specific text | Excel Discussion (Misc queries) | |||
Searching for a variable field | Excel Programming | |||
Searching for specific text | Excel Programming |