hi ,

i have a textbox control in one sheet and a range of data in another sheet in the same file. how do i copy the range of data in paste it in the textbox control?

appreciate a reply thanks

is this access or excel you are talking about

is this access or excel you are talking about

this is in excel i am talking about

this is in excel i am talking about

if you go to Deleloper Tab there is a way to add textbox i am tring to write a macro to copy data from another sheet (a range of data) and paste it to the textbox how do i do it?

the simplest way is to go to Tools -> Macro -> Record New Macro
manually do what want, the macro will create the VBA for you, you can then go into the Visual Basic editor to look at, improve the code.

the simplest way is to go to Tools -> Macro -> Record New Macro
manually do what want, the macro will create the VBA for you, you can then go into the Visual Basic editor to look at, improve the code.

yes i did that but when i do that the macro dosen't record when i paste the content to the textbox, because text box dosen't have a method paste

Dim contents As String
contents = ""
For Each c In Worksheets("Sheet2").Range("a1:a4").Cells
  contents = contents & ", " & c.Value
Next c
TextBox1.Text = contents
Dim contents As String
contents = ""
For Each c In Worksheets("Sheet2").Range("a1:a4").Cells
  contents = contents & ", " & c.Value
Next c
TextBox1.Text = contents

thnaks for the help
i did that, but the only thing is can't get the format of the data range that i an putting to the textbox,
how can i do that?

There is a format$ function that will format things for you. for example for a money amount

contents = format$(c.value,"currency")

There is a format$ function that will format things for you. for example for a money amount

contents = format$(c.value,"currency")

so if i have a format as


A $5.00 $7.00 $2.00
B $(5.00) $(9.00) $6.00
C $8.00 $(8.00) $(4.00)
D $2.00 $(9.00) $7.00

so i have something like above how to i display exactly the same way in the textbox?

have you looked at the Help for format$ that should tell you

yes i looked at it
but the range i am going to copy it has number string $ amount so can't format into one format right
how can i do this

hi do you know a way of doing it????

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.