Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VBA to copy text from one Textbox to another - Excel..

Status
Not open for further replies.

basepointdesignz

Programmer
Jul 23, 2002
566
GB
Hi,

I need to populate a textbox with particular information from another textbox, once a cell is activated..

What I mean is that I have a form, which one cell contains a list of customer number (ie ABI001). What I want to do is populate the "address" textbox (required for multiline information) with the address of the customer, which is in another textbox elsewhere in the spreadsheet. So, for example, when the ABI001 customer number is chosen the form fills out with the relevant customer info.

I've tried recording a macro to see what code is generated and also tried to code it by hand but I can't get it to work.
Could the problem be in addressing the cell correctly? It's a merged cell, so it's absolute address is something like $A$1:$B$2 but this still doesn't work. I've even tried to name the range but still won't work..


I have the following code which is half recorded and half hand coded

Code:
Sub Input_Company_Details()

Dim Target As Range  'Range of Cells..

Select Case Target.Address
    Case Is = "$E$10:$F$11"  'The Customer Number cell..
   
' ABICAD LTD..
If Target.Value = "ABI001" Then

    'Add Company name..
    Cells(13, 17, 14, 18) = "AbiCAD Ltd"
  
    ' Populate the address textbox..
    ActiveSheet.Shapes("Text Box 9").Select
    ActiveSheet.Shapes("Text Box 9").Text = ActiveSheet.Shapes("Text Box 29").Text  
End If

End Select

End Sub



What could be the problem(s)?



Cheers,

Paul @ basepoint designz..


basepoint designz
renegade@tiscali.co.uk
 
Hi,

Merged cells will complicate you codeing and cause problems.

What is...
Code:
    'Add Company name..
    Cells(13, 17, 14, 18) = "AbiCAD Ltd"
supposed to do?

The syntax for Cells is...
Code:
Cells(row, col)
so
Code:
Cells(1, 1)  is equivalent to [A1]


Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top