[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to get TextBox values into Excel cells

Posted on 2001-09-11
7
Medium Priority
?
217 Views
Last Modified: 2011-04-14
Hi!

I have an Excel spreadsheet containing a lot of textboxes. I want to extract the values in these textboxes and get them into the cells in the spreadsheet. I've tried to write a macro but it halts on the
Activecell = ActiveSheet.Shapes... line and I cannot find out what's wrong.

Dim Teller As Integer
Range("a1").Activate
For i = 116 To 228
ActiveSheet.Shapes("Rectangle " & i & "").Select

Activecell = ActiveSheet.Shapes("Rectangle " & i & "").Value

ActiveCell.Offset(0, 1).Select
Teller = Teller + 1
If Teller = 4 Then
ActiveCell.Offset(1, -4).Select
Teller = 0
End If
Next i

Can anyone help?

Regards
bernjerg
0
Comment
Question by:bernjerg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 22

Expert Comment

by:ture
ID: 6473551
bernjerg,

Try using this line of code instead:

Activecell = ActiveSheet.Shapes("Rectangle " & i & "").Characters.Text

Ture Magnusson
Karlstad, Sweden
0
 
LVL 22

Accepted Solution

by:
ture earned 600 total points
ID: 6473556
...or, if you prefer, you can use this VBA code instead of yours:

  Dim i As Integer
  Dim c As Integer
  Dim rng As Range
  Dim sh As Shape
 
  Set rng = ActiveCell
   
  For i = 116 To 228
   
    Set sh = ActiveSheet.Shapes("Rectangle " & i & "")
    rng.Value = sh.TextFrame.Characters.Text
   
    Set rng = rng.Offset(0, 1)
    c = c + 1
    If c = 4 Then
      Set rng = rng.Offset(1, -4)
      c = 0
    End If
 
  Next i

/Ture
0
 

Author Comment

by:bernjerg
ID: 6473601
Tackar s? mycket! Actually, I found it out in the meantime. By the way... Do you know a method to make Excel find the Rectangles in the spreadsheet? I tried to write "For each Rectangle In ActiveSheet" But that didn't work out.

I've increased the points to 150.

Regards
bernjerg
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:ture
ID: 6473670
bernjerg,

Vars?god!

> Do you know a method to make Excel find the Rectangles in the spreadsheet?

Something like this? It finds BOTH rectangles and text boxes, which are actually the same kind of shape.

Please note that I have changed the variable name from "sh" to "shp" (to avoid confusion between shapes and sheets).

  Dim c As Integer
  Dim rng As Range
  Dim shp As Shape
 
  Set rng = ActiveCell
   
  For Each shp In ActiveSheet.Shapes
 
    If shp.AutoShapeType = msoShapeRectangle Then
   
      rng.Value = shp.TextFrame.Characters.Text
     
      Set rng = rng.Offset(0, 1)
      c = c + 1
      If c = 4 Then
        Set rng = rng.Offset(1, -4)
        c = 0
      End If
   
    End If
 
  Next shp


> I've increased the points to 150.

No, you haven't :0)

/Ture
0
 

Author Comment

by:bernjerg
ID: 6473693
Great! Now you've got your points. My mistake...

bernjerg
0
 
LVL 22

Expert Comment

by:ture
ID: 6473706
Thanks, bernjerg! I didn't know that it was possible to increase the points AFTER accepting a question. How did you do that ???

/Ture
0
 

Author Comment

by:bernjerg
ID: 6473728
I had a not updated browser window open in the background and I could increase the points from that window. I wasn't sure if you would get those points by trying to raise the points afterwards, but it seems to work just fine.

bernjerg
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question