Pass Values From Cells To Shape
Nov 30, 2007
I am trying to convert some text from a number of cells to shape in another workbook. The problem is, if the text in one of the cells is too long (from testing it by too long i pretty much mean roughly 100 characters) then it doesn't pass anything at all to the shape. Is there a way around this so that all text will be converted to the shape regardless of its size?
By the way, the code is:
ActiveWorkbook. Sheets("Sheet1").Activate
ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text = "1. " & Priority1Range.Value & Chr(10) & "2. " & Priority2Range.Value _
& Chr(10) & "3. " & Priority3Range.Value & Chr(10) & "4. " & Priority4Range.Value & Chr(10) & "5. " & _
Priority5Range.Value
The variables 'Priority1Range' represent the cell the text is in that I am trying to pass and it's variable type is Range. I have tried declaring the Priority1Range.Value as a string variable and using this instead but this doesn't work.
View 9 Replies
ADVERTISEMENT
Feb 27, 2008
I've created a variable number (i) of text boxes at run time (i also named them, "txt"&i, at the same time), i'm now trying to get the values entered in these to fit into a column that has been inserted during the same sub routine. I'm having a bit of trouble refering to the text boxes though, this is the patch of code i'm struggling with:
Dim TextBox As String
For i = 0 To 2 * NumVar - 1
TextBox = "txt" & i
ActiveCell.Offset(i, 0).Value = TextBox.Value
Next i
I also tried this:
Dim TextBox As Object
For i = 0 To 2 * NumVar - 1
TextBox.Name = "txt" & i
ActiveCell.Offset(i, 0).Value = TextBox.Value
Next i
View 8 Replies
View Related
Mar 15, 2014
I have a couple of hundred string values in column A. I am trying to create the same number of rectangle shapes in column B, each one taking its name from the corresponding cell in column A. I keep hitting the dreaded 400 error code .
Attached File : test add shapes.xlsm
View 3 Replies
View Related
Jan 1, 2007
i am trying to enter the EndX coordinates (The third number: 500) by entering a number in a forms textbox
ActiveSheet.Shapes.AddLine(0, 100, 500, 100).Select
how can i break the code up to enter the coordinates via textbox's
View 6 Replies
View Related
May 27, 2007
Is there a way to make the colours in a chart (pie, column etc) correspond to a value? I'm using Excel 2002, soon to start using 2003.
For example, imagine a normal pie chart showing the population of each country in North, Central and South America. But for each country, colour gradations would be used to show levels of wealth (e.g., GDP per capita) as follows:
saturated red = bottom 20% (poorest)
pink = 21-40th percentile,
white = 41-60%,
gray = 61-80%,
black = 81-100% (richest)
Is this possible? And not to get too greedy, but can you use even finer gradations -- say, with ten categories, as opposed to the five in the example above?
View 9 Replies
View Related
Oct 27, 2008
i have two arrays that I want to use in a trend function. I don't think i can just use the array as is in the fucntion so my guess is that I need to pass the array into a range of data, and help on how I can do this? (also this is in VBA, fyi)
View 9 Replies
View Related
Sep 18, 2009
i'm trying to do my homework which requires me to pass values from an array in excel worksheet to VBA and print it in a msg box
i've tried
dim arr as variant
arr = range("A1:A6").value
msgbox arr
but it didn't work.
that's the first step of the homework the second is i have 2 list of array
year:1999 - 2002
profit:10,20,30,40
i have to find the max profit and get the year when it occurs
View 9 Replies
View Related
Nov 20, 2008
I have Workbooks("A") and Workbooks("B") open.
Workbooks("A") contains Sheets("Sheet1"). Range("mySource").
Workbooks("B") contains Sheets("Sheet1").Range("myTarget").
Both ranges have been created by joining multiple ranges, in this way:
Union(Range("C1:C13"), Range("K1:K2"), Range("K5:K9"), Range("K14"), Range("Q6"), _
Range("I18"), Range("B20:P20"), Range("B24"), Range("C26:E26"), Range("C29"), _
Range("B34:B40"), Range("B44:Q50")).Name = "mySource" 'or "myTarget"
So: both ranges contain the same number of cells with the same addresses, and they have been added in the same order. However, if now I try to pass all values from mySource to myTarget, in this way:
Workbooks("B").Sheets("Sheet1").Range("myTarget").Value = _
Workbooks("A").Sheets("Sheet1").Range("mySource").Value
the result is a complete mess. Only the first "subrange" of mySource ("C1:C13") is passed to myTarget, and pasted in each of its "subranges", sometimes by rows and sometimes by columns...
View 2 Replies
View Related
Nov 21, 2008
You have an array and a range of the same size and you have to put the array values into the range, something like this:
Dim i As Integer
Dim myCell As Range
Dim myArray(10) As Double
i=0
For Each myCell In Range("A")
myCell.Value = myArray(i)
i = i + 1
Next myCell
except that this code looks a bit awkward to me.
View 2 Replies
View Related
Nov 20, 2007
I'm just starting to experiment with passing values between workbooks and between modules and so far I've managed to get it working. However, I now can not run the receiving module independently because of the passed value ? Let me explain ...
I use start/end dates within my modules to create date sensitive reports. I have several files (for different departments) and each file has a module called "AbsenceChecker", I have been working on a way to create a Report Master workbook to run and amalgamate the "AbsenceChecker" module from each department.
Sub RunAllLoaders()
Dim AbsenceStart As Date, AbsenceEnd As Date
Dim PassVar1 As Date, PassVar2 As Date
Dim DateStart As Date, DateEnd As Date
On Error Resume Next
'start of data validation script continued in private sub.
GetValidDates FromDate:=PassVar1, _
ToDate:=PassVar2, _
MinDate:=DateSerial(2007, 1, 1), _
MaxDate:=DateSerial(2007, 12, 31)
Excel.Application.EnableEvents = False
Workbooks.Open Filename:="R:RostersRosterALPHA.xls"
Application.Run "RosterALPHA.xls!AbsenceChecker", PassVar1, PassVar2
End Sub...................
View 2 Replies
View Related
Jan 16, 2008
I have userform1 with commandbutton1 and listbox1. From listbox1 you make a selection and then you click commandbutton1 and it calls up another form (userform2.) On userform2 I have a label that I need to capture the value highlighted in listbox1 form userform1. How do I write this code to have label update to the listbox selection?
View 2 Replies
View Related
Mar 4, 2009
when i run the below code i get an error 438 'object doesnt support this property or method'
View 2 Replies
View Related
Oct 18, 2006
I have a worksheet which I've set to read-only, I am trying to get it to pull in information from external worksheets. I've created a Macro that will automatically bring in the data however it will only go into a pre-defined cell/row. I have another Macro which looks up the next available row (which is where I want the data to go) but can't get it to link into the macro's. In short, Macro1 brings in data, Macro2 finds next available row, Macro3 brings in another worksheet, Macro4 finds next available row etc etc.
Sub Macro3()
With ActiveSheet.QueryTables.Add(Connection:= Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:Documents and SettingsjspencerDesktopExcelAMMH.xl" _
, _
"s;Mode=Share Deny Write;Extended Properties=""HDR=NO;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database" _
, _
" Password="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Locking................
View 2 Replies
View Related
Jan 1, 2008
how is the best method to link up forms to "talk" to my modules? (aka set variables inside my module script)
the way i understand it with my C++ background, it seems like separate forms and modules act much like private declarations do inside class calls.
I know that in C++ i can declare a friend class to grant access to communication between classes... and i'm wondering if such a procedure is possible in VBA as well...
or to break it down for those not familiar with C++, quite simply, is there a method of code i can implement to have different user forms and modules to talk to eachother? as it seems that any variable declaration is all inclusive to that one object.
The only way i can think of passing variables is by having my code create a worksheet, paste variables one by one into cells, bounce to the destination module, and import those declarations one by one through the cell contents, and remove the sheet after use...
I know i can do it that way, but i really dont want to as that is pretty darn sloppy, and a mickey mouse way to tie my program together.
View 3 Replies
View Related
Apr 19, 2008
I have been trying to use a multi-select listbox as the argument for a subroutine. For some reason, I keep getting a run time error, type mismatch. I'm baffled because when I define the specific listbox, it works fine, but when I attempt to pass the listbox I get an error.
Public Sub OtherDirectTotal(Expense As ComboBox, CostCat As ComboBox, _
Cost As TextBox, Years As Msforms.listbox)
Dim IDC As Double
Dim IDCt As Double
IDC = Val(UserForm2.txtIDC) / 100
If Years.Selected(0) = True Then
If Expense = "Sponsored" Then
If UserForm2.ChkODC = False Then
Select Case CostCat......................
View 2 Replies
View Related
Aug 30, 2006
how can i store the values of an autofilter's list in a array using VBA.
View 4 Replies
View Related
Mar 12, 2009
I have a shape object which is created dynamically.
Now onAction event of the shape object, I need to get the cells row and column number where the shape object is sitting. How can i get it?
View 6 Replies
View Related
Jun 27, 2014
following code is supposed to check whether cell contains a value and based on that either display or hide a shape. The last couple of lines are moving it. What I would need is to check all cells in a row (not only the first one) and if lets say first 1,2,3...10... cells contain a value move the shape all the way to the end of that cell and so on.
VB:
Sub Worksheet()
If Sheets("Text").Range("z6") <> 0 Then
With ActiveSheet.Shapes("Rectangle 8").Fill
[Code].....
View 4 Replies
View Related
Sep 24, 2008
if I wanted to slowly move a shape (small circle) in a straight line between cells R20 & W7.
The straightest line possible is by drawing an arrow line between the 2 cells.
Is there a way to then use this arrow as a guide for moving the shape?
In other words, would it make sense for the porgram to draw a transparent line between the cells, and use that line as a "path" along which to move the shape?
I just don't know if this is worth the trouble.
View 9 Replies
View Related
Nov 8, 2006
I have the following code. I need the textbox values to pass to the cells when the option button (OB) is "moved away from"; that is, when I fill in the boxes while uner OB1, then select OB2, I want the values I put in to pass to the cells. Right now, the values passing to the cells listed under OB 1 are the values that are brought in under the enter event for OB2.
Private Sub OptionButton1_enter()
Me.TextBox1.Value = ActiveCell.Offset(0, 9).Value
Me.TextBox2.Value = ActiveCell.Offset(0, 10).Value
Me.TextBox3.Value = ActiveCell.Offset(0, 11).Value
Me.TextBox4.Value = ActiveCell.Offset(0, 12).Value
Me.TextBox5.Value = ActiveCell.Offset(0, 13).Value
Me.TextBox6.Value = ActiveCell.Offset(0, 14).Value
Me.TextBox7.Value = ActiveCell.Offset(0, 15).Value
Me.TextBox8.Value = ActiveCell.Offset(0, 16).Value
End Sub
View 9 Replies
View Related
May 12, 2014
I have a test log with PASS/FAIL. These results are logged in Excel under the column heading PASS/FAIL.
How do I count the number of PASS or FAIL using VBA macro?
So far I have tried:
[Code].....
This one did not work either:
[Code] .......
the error is at the name = Range("PASS/FAIL").Select line.
My thought process: once I had selected a range, I can now freely "look" at each string in a cell in that range. Not correct I guess.
All this is currently done in the active sheet.
View 3 Replies
View Related
Jan 24, 2014
On the attached spreadsheet there is two irregular shapes. "Area1" & "Area2". I need to be able to determine which area the "ball" shape is located in. If the ball is in Area1 then "Multiply 8" gets the ball and "Multiply 9" moves to the blue cell "AH39". If the ball is in "AreaB" Multiply 9 gets the ball and "Multiply 8" runs to cell "S37"
I should be able to do the moving of the shapes using all the samples, its determining which area the ball is in is the problem.
In the real spreadsheet i will probably have around 10 different Areas.
Move Two Objects - Select Case.xlsm
View 5 Replies
View Related
Feb 13, 2008
I have a WAY to complicated excel form that I'm going to move to Access but I need to have this working in the interim. The form has a dynamic element, the user can choose the number of items they are ordering and it unhides the required number of text boxes. To keep the scripting down a did a little work-around to update the database using a loop through the form controls:
'Save the main row
MainOrderRow = ActiveCell.Row
LastRow = MainOrderRow + (ExtraOrders - 1) ' Calculate the last row
ExtraOrderNo = 1
For DBRow = MainOrderRow To LastRow
' Save the text box name with the extra order number
k = "txtDescriptionMul" & ExtraOrderNo & ""
l = "txtQuantityMul" & ExtraOrderNo & ""
m = "txtTotalValueMul" & ExtraOrderNo & ""
n = "ComboBoxUnitMul" & ExtraOrderNo & ""...................
View 2 Replies
View Related
Jun 23, 2009
I have D4=0.42. I thought this formula =IF(D4<0.38,"Thin",IF(0.38<D4<=0.48,"Good shape","Bad shape")) was supposed to give me "Thin" for D4<0.38, "Good shape" for 0.38<D4<=0.48 and "Bad shape" for the contrary, but it only gives me "Bad shape" when D4 is clearly between 0.38 and 0.48.
View 4 Replies
View Related
Oct 27, 2009
I M trying to get the lower values between to cells and have the lower valued cell highlighted,,,i have over 43 thousand lines of data to go throughand i was wondering if there was a quicker way to do this,,,for example cellA1 is $4.25 and cellA2 is $5.25 i want cell A1 to be highlighted,,is there a way?
View 2 Replies
View Related
Dec 9, 2008
I did my search, but cant find and knows what key search to look/type for...
If i have data A1 through A10, such as 1 1 2 2 2 2 3 3 3 3
How can i get column B1 through B3 as 1 2 3 ?
View 9 Replies
View Related
May 22, 2014
What I have In Column B, I have the datesIn Column I, I have engineers name What I need I want a macro to generate Serial Nos. (1,2,3....... n) in column A If an only if the date in column B is today's date and the engineer's name matches with the PC's username
The following is my code
[Code] ....
Above code runs without errors but does nothing.
View 4 Replies
View Related
Mar 14, 2013
I am trying to replace a range of cells with certain values but I can not figure it out. I'm almost there I think but don't know how to get the varying values I'm looking for. So I have a column (AJ in this instance) that has a bunch of "xx" values at different spots within the column. I want to replace those xx values with numbers 01 through 36. What I have below gets me just about there but it replaces every xx value with 01. How do I get it to go 01 on the first one, 02 on the second one, etc?
/code
Dim cell As Range
For Each cell In Range("AJ1", Cells(Rows.Count, "AJ").End(xlUp))
If cell.Value = "xx" Then _
cell.Value = "01"
Next cell
/code
View 3 Replies
View Related
Aug 24, 2009
code doesn't work
Sub test()
If ActiveSheet.Shapes.Name = ("five") Then
Range("B4").Select
Else
Exit Sub
End If
End Sub
View 9 Replies
View Related
Feb 2, 2010
I have a shape in Excel called Canada. I grouped it with another shape and want this new grouping to be called Canada. But when I enter Canada in the shape name entry box, it doesn't actually change it (as it thinks I am referring to the existing Canada).
I need something like Names manager, but for shapes, not ranges.
View 9 Replies
View Related