Array As String And Integer Together
Sep 19, 2007
I have defined array say like this:
Dim myarray (1 to 5, 1 to 2)
Is possible to define something like this?
myarray (x, 1) as string
myarray (x, 2) as integer
x is anything between 1 to 5 .
View 9 Replies
ADVERTISEMENT
Jun 21, 2014
wondering is there a VBA equivalent of --() in excel that turns trues and falses to 1's and 0's?
View 14 Replies
View Related
Sep 19, 2009
I am trying to concatenate some string and integer. It is always for previous month end date, i.e, 7/31/2009 or 8/31/2009.
Here is I have the data now
Profit and Loss for
After running the macro I would like to be
Profit and Loss for 8/31/2009
Here is what I wrote so far which does not work. I am sure there is simpler way to do it. I put the month end date 5 columns to the right for the time being and in the intention after deleting it after concatenation automatically.
For Each cell In Selection
ActiveCell.Offset(0, 5).Value = "=EOMONTH(TODAY(),-1)"
ActiveCell.Offset(0, 5).Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.NumberFormat = "m/d/yyyy"
View 9 Replies
View Related
Mar 31, 2014
I am trying to do a sort of index match thing using VBA. What I am attempting to do is to use the prefix of a long number and try to find that exact prefix in a string array, and output that string array value. So this is what I have so far as a test:
[Code].....
So I can match the text exactly so if I put PREFIXB in cell A1 in this example, i will get the msg box saying "YES", but if I make it PREFIXB1231k4j3jj1kj32cj, it will display "NO". I want to get it so that PREFIXB will be displayed in the cell that I put the formula in. So if A1 = "PREFIX1AAA100CF" and cell B1 = "=ABC(A1)", cell B1 will display "PREFIX1AAA".
Now the thing is that these prefixes can have different lengths, but will never encompass the exact prefix of another. So if I had a prefix of: PRE1AB, I won't have a prefix of PRE1A.
View 2 Replies
View Related
Aug 3, 2009
I have a string in one of the following formats:
Banana 2, Orange 5, Lemon 0
Banana 7, orange/Lemon 9, cucumber 6
Melon/grape 3, Pineapple/ Orange 1
Banana 1, orangefruit/Lemon 2, pine 8
I would like to take out the first integer that comes after the word Orange (not case sensitive). I'm kinda at a loss here, how do I go about accomplishing this?
View 9 Replies
View Related
Feb 22, 2010
I am not quite getting how to test a value if it is an integer or a real.
If A1 = 10.4 I want to skip that cell, if A1 is 10 I want to process that cell.
View 12 Replies
View Related
Feb 16, 2014
I've got an odd program that exports time data formatted as a text string. For example....
0:10:25
Since it has no numerical value, then I can't simply "format as number". I'm thinking that I will need to use one of the string methods eg: mid() to check each character individually and then convert that into the equivalent numerical value.
So the numerical output I am looking for in the above example would be 625.
View 2 Replies
View Related
Feb 19, 2014
for ii = 1 To 3
shts = "XX0" & Str(ii)
Create_worksheet (shts)
Next ii
when I run this, my worksheets are like
"XX0 1"
"XX0 2"
"XX0 3"
what's wrong that I did? How can I do "XX01"...?
View 3 Replies
View Related
Jan 15, 2009
I have an array of data with both positive and negative numbers. I want to locate the largest number (farthest from zero) regardless of sign. But I will need to retain the sign because I will be dividing every number in the array by that number to normalize the array to values between 1 and -1?
View 12 Replies
View Related
Nov 29, 2013
I have a cell that gives a title and then a cell value:
="Design and Build "& if(B19>=0,B19,0)
The issue is, I need the B19 value it displays to be an integer. Right now it's giving me about 8 decimal places. I've tried formatting that cell and the cell it calls, but neither has any effect.
View 2 Replies
View Related
Mar 13, 2012
I am trying to name a Range in VBA with the following Case statement.
Select Case counter
Case "2": Set Wk(numWeeks) = Range("P1:Q136")
ActiveWorkbook.Names.Add Name:="Wk" & numWeeks, RefersTo:=Wk(numWeeks)
I have many more cases and have defined Wk(5) as a Range. What I am really after it is possible to to name the range using something similar to the code above that uses a predefined variable in the naming process.
View 4 Replies
View Related
Jul 5, 2012
Is it possible to count the number of indexes in an integer array that have a value > 0 without looping through the array? I found something using Filter, but that only appears to work on string arrays.
View 2 Replies
View Related
Oct 2, 2006
i did some VBA quite a while back, and picking it up again.
I'm trying to get a function to read in a string, and return a value based on the string value.
Public Function value(ItemType As String) As Integer
If ItemType = " Upper" Then
value = 40
ElseIf ItemType = "Middle" Then
value = 50
ElseIf ItemType = "Lower" Then
value = 25
End If
End Function
When i tried using it at the Cell level, it keep giving error i.e. Invalid Name Error
View 9 Replies
View Related
Jul 30, 2012
in C a string is nothing more than an Array of characters ending with a null character.
in VBA this does not seem to be the case.I am trying to use the BlowFish code from David Midkiff for some encryption, however the code sometimes fails:
When encrypting a string a string of a specific length should be returned. however sometimes one of the characters of the encrypted string is a null character, and the returned encrypted string (with a embedded null character) is causing me problems. I want to check for the null character and if present redo the encryption. But how do I check for the presence of this null character in a unicode (double-byte) string?
Checking with Len(encrypted) gives the correct length (!) but trying to move each (unicode)character into an array fails when using the Mid() function past the null character in the string.
Now I can use
byteArray() = StrConv(unicodetext,vbFromUnicode)
to get the lower byte of each character into an array easily, but how do I do this for both bytes of the unicode characters?
Using an integer array does not work other than through
intArray(j) = CInt(AscW(Mid(Outp, j, 1)))
which fails on the nullstring in my encrypted text.
I have tried with variants but so far no luck. I thought if the string was entered into a variant then I could also address the variant as an array of bytes, but that does not seem to be accepted by VBA.
View 1 Replies
View Related
Dec 20, 2013
I need to export this to Xcelsius which doesn't support any macros/vba. Btw I can;'t use Row() in xcelsius too.
[Code].....
View 4 Replies
View Related
Oct 2, 2008
I have a class module with several private variables, including one that is an array of a user-defined type. I am trying to set the values of a single element of this array with "Property Let ..." from a string array:
View 4 Replies
View Related
Aug 8, 2013
I have list of strings to be searched in column A2 to A150 (A1 has column title). The array that needs to be searched is in B2 to AG1000 (B1 to AG1 has column title). I want each string in column A to be searched in the full array. If match is found the corresponding column title (B1 or C1 and so.) and cell address needs to written to a new result columns in AY and AZ. it should work for duplicates as well i.e. the string can be in all the columns of array from B to AG. and all of them needs to be written to result column.
View 9 Replies
View Related
Sep 26, 2013
I'm trying to verify if a cellvalue is available in an array. Here is the code:
First I tried to check if the cellval is in the array by returning a -1, 0 or 1:
Code:
If UBound(txt, cellval) = 0 Then
-> returns zero for value "h3", but also for value "3"
(where cellval the value in the cell is)
(with txt being the array containing "h3,r8,ty657", etc)
But I need only the If to be true when there is an exact match.
View 2 Replies
View Related
Sep 20, 2008
Say I have a string, "a test array." I want to split this into an array where each character is an element. I was thinking something like
Dim MyArray As Variant
Dim MyString As String
MyString = "a test array"
MyArray = Split(MyString, "", Len(MyString), vbTextCompare)
But this doesn't work because Split() returns the entire string when the delimiter is a zero-length string.
View 9 Replies
View Related
Feb 17, 2009
I'm trying to pass an array of UDT from Excel to a C++ dll but I have no idea how. My UDT looks like this
Private Type Student
Age As Integer
Name As String
StudentID As String
End Type
And my dll function declaration..
Declare Function RegisterStudent Lib "SimpleDLL.dll" _
(arr() as Student) As String
.. which will return a unique Id in string
View 9 Replies
View Related
Nov 18, 2006
I have a string (PreString) that gets its values from a procedure call (PreResult). The string consists of 4 values for each loop which I then split into the y array.
I then want to transpose the array to the worksheet for sorting.
I don't really get the transpose to work as I want to. I want every 4:th y to be printed on a new row (x). I don't really know how to use the Ubound function to get it right.
Should I make a 2 dimensional array instead ? If so, how is that made ?
Dim x As Integer, z As Integer
Dim var_Status As Integer
Dim var_Week As String
Dim var_HoursPerWeek As Integer
Dim PreString As String
i = var_StartWeekNr
j = var_RangeNumberOfWeeks
z = 0
x = 0
var_Status = 0
var_Week = ""
var_HoursPerWeek = 0
PreString = ""
View 8 Replies
View Related
Nov 9, 2009
I want to extract data from array string and then sum the values. For reference attaching the excel.
View 14 Replies
View Related
Jul 30, 2013
I set out this morning to count duplicates in an array and report a succinct list.... so I went down the route of using a collection with keys to do this.
1. Is there a better way? Else
2. split my collection values? I'm a bit stuck.
I have a series of values in a collection like this
: Item 2 : "Spam|01/07/2013|1" : Variant/String
: Item 4 : "Chips|01/07/2013|2" : Variant/String
So I have 3 key pieces of data delimited by a pipe sign -
Product | Date | Number of Occurrences
Item 4 is of interest to me because it occurs twice.
How I can turn those collection values into something I can work with, else another approach to sum rows in an array which are duplicates (if you only look at 2 columns).
View 6 Replies
View Related
Sep 2, 2013
I have a test to see if a text string is in an array that mostly works, but sometimes fails and I don't understand why.
The routine calls a Function IsInArray which returns a True/False value depending on whether the search term is in the array.
Code:
Sub TestFilterArray()
MyArray = Array("a", "b", "c")
If IsInArray("a", MyArray) = False Then
[Code]....
In this case the first item in my array is "a - b" (note that this is a text string ), but for some reason because my test value is "a" the routine things it must be in the array.
Thus I am thinking that the ampersand and dash symbols are somehow confusing my routine.
How can I change my routine so that it correctly identifies which text strings are in my array?
View 9 Replies
View Related
Apr 18, 2007
I have a function that will be used across 10K+ records at a time, so I was taking a look at optimizing it a bit. At the start of the routing I have a string with a 9 to 15 digit numeric value in it. I wanted to load each individual digit into a byte array. I started out using:
byVal = StrConv(sVal,vbFromUnicode)
But that actually loads the ASCII Character codes into the array not the digits themselves. From there I considered looping through the array applying CByte(Chr$(byVal(i))) but then I wondered if it would make more sense to just load the array with Mid$(sVal,i,1)... Does anyone have tested knowledge on which performs better? Is there an option C I have missed?
View 9 Replies
View Related
Oct 1, 2008
I have a string that I need to sort.
Below code works beautifully but doesn't sort numbers, any advice to get this to sort numbers as well?
Function Alphabetize(ByVal sText As String) As String
Dim sWords() As String, sTemp As String
Dim i As Long, j As Long, n As Long
'-- clean up text
For i = 1 To Len(sText)
Select Case Mid$(sText, i, 1)
Case " ", "a" To "z", "A" To "Z"
Case Else: Mid$(sText, i, 1) = " "
End Select
Next
'-- remove leading and trailing spaces....................
View 9 Replies
View Related
Mar 11, 2009
I'm having a problem with the below array. The column heading in cells E7:H7 Never change and i would like to sum up the appropriate data below those headings according to the what is in cell D4. The formula in cell A9 works but only if the string is exactly the same as what is listed in cell D4. Is there a way to reference cell D4 like i have in cell B9. I'm looking to get the formula in B9 to work, but i'm missing something.
Sheet1
ABCDEFGH2Assumptions 3Collateral Sample 1{60;90;FCL} MACRO Populates 4Collateral Sample 2{90;FCL} {60;90;FCL} 5Collateral Sample 3{FCL} 6Collateral Sample 4{60;90;FCL} 7 Current6090FCL8 990 123410200 658711360 4682212
Spreadsheet FormulasCellFormulaA9{=SUM(IF($E$7:$H$7={60;90;"FCL"},$E9:$H9))}B9{=SUM(IF($E$7:$H$7=$D$4,$E9:$H9))}A10{=SUM(IF($E$7:$H$7={60;90;"FCL"},$E10:$H10))}B10{=SUM(IF($E$7:$H$7=$D$4,$E10:$H10))}A11{=SUM(IF($E$7:$H$7={60;90;"FCL"},$E11:$H11))}B11{=SUM(IF($E$7:$H$7=$D$4,$E11:$H11))}Formula Array:
Produce enclosing { } by entering
formula with CTRL+SHIFT+ENTER!
Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4
View 9 Replies
View Related
Mar 28, 2007
is it possible to declare an array or anyother datatype like the following in VBA?
Dim myArray() As Integer
myArray("A") = 0
myArray("Test") = 0
myArray("G") = 0
after checking some conditions i need to change the corresponding values too, like the following,
If mycondition = True Then
myArray("Test") = 1
End If
View 9 Replies
View Related
Jun 8, 2007
I have a string which follows this format: "App Alg FMA", "App Pgm FMA", "App Slf FMA" This string can shrink or grow dynamically depending on the number of App*'s selected. How can I split this string and load the App*'s into an Array so the array would contain the following
Array(0) = "App Alg FMA",
Array(1) = "App Pgm FMA",
Array(2) = "App Slf FMA",
View 2 Replies
View Related
Jun 30, 2014
I have a long list of terms, and I need to identify which of these terms appear in another body of text strings. Rather than searching for each individual term, is there a formula that check the terms for me automatically.
The terms will appear in the larger body of text, but they won't appear on their own, so they won't be perfect matches.
I've attached a sheet to try to illustrate the problem.
Term Checker.xls
View 5 Replies
View Related