Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Excel


VBA How To Read Cells Into Variables/array And Use In String

I made the formula work great, however I want to cut it down and simplify it and make it easier to manipulate... as opposed to having the filename written every so many times.. replace with a loop instead.... so:

Private Sub Weeklytestt_Click()
Dim varCurDate As String
If DateYesterday.Value = True Then Answer = "1"
If DateToday.Value = True Then Answer = "2"
If DateTyped.Value = True Then Answer = "3"

Select Case Answer
Case Is = "1"
varCurDate = Format(Date, "yyyymmdd")
varCurDate = varCurDate - 1
Case Is = "2"
varCurDate = Format(Date, "yyyymmdd")..........

View Complete Thread with Replies

Sponsored Links:

Related Forum Messages:
Array Variables In VBA
Is there any way to add together a portion of an array without using a loop or for statement. i.e.) I have a array variable: arrayvar = array ( 1, 2, 3, 4, 5)

is there a way to sum the last two numbers in the array without using

arrayvar (3) + arrayvar (4) or a loop or for statement.

I am thinking something along the lines of worksheetfunction.sum( arrayvar( 3 to 4)) I know that this does not work but I hope you can see what I am trying to do

View Replies!   View Related
VBA Sort String Array Function
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
'-- remove leading and trailing spaces....................

View Replies!   View Related
VBA - Read Values Of Many Cells
Excel 2003 > I am developing a comprehensive VBA function that needs to read the value of many cells in a worksheet. I don't want to Name all those cells because then I will need to pass too many variables to the function. I can use the following set of objects and properties ...

View Replies!   View Related
Declare A Const Array Of String Type In VBA
How do I declare a const array of string type in VBA? for example I want to say
Const myStringArray(4) as String = string1, string2, string3, string4

View Replies!   View Related
Evaluate Expression In VBA Using Cells As Variables
I need a nudge in the right direction here. I have found several examples on the board that have spawned some ideas but need a little more help.

I am looking to enter variables into 2 columns A and B and then run these variables through an expression.

I have already done basic cell math and want it to be cleaner by using VBA to run the calcs and then spit the answers back into the spreadsheet.

I think I have an idea as to how it need to function but do not know the exact commands to make it efficient.

View Replies!   View Related
Code To Read A Formula As String
I am using the following code to read a formula as a string. But sometimes the use r may forget to enter formula in the particular cell. In this case I want to check if the first character of the string is a Equal-to Sign (=). In case it is then macro proceeds further otherwise a message prompts user to enter a formula first. how to check if the first character of the string is a '=' sign?

View Replies!   View Related
Read A Range Into An Array
In a Worksheet named "Input" and in Cells "B3:G?" I have 6 number groups. How can I ...

( 1 ) Put each of the 6 number groups into an array when I don't know what the last row number is.

( 2 ) Find the maximum value in any of those cells and attach it to a variable named MaxVal.

... so once I have done this I can then loop through each 6 number group and perform some calculations.

View Replies!   View Related
String Array Values To Array Of User-Defined Types
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 Replies!   View Related
Read Worksheet To 2nd Array
I have a worksheet with 7 columns and I would like to read this into a 2d array. The worksheet can have as much as 50k rows.

1) is it possible to read 50k rows into a 2d array?
2) is it more efficient to read data into an array for access/manipulation as opposed to a worksheet?
3) can someone show me how to read in a worksheet with 7 cols to a 2d array?

View Replies!   View Related
Read Values From One Workbook Into An Array
I am trying to create a "macro" that will read values from one workbook into an array based on a key field. If the key isn't present the cells data is not to be stored. After the records are stored i want to test them agains a range in a differnt workbook. If the data compared matches a stored value, leave it alone. If there is no match, a cell needs to be added with a value stating a differnce.

Like i stated i am new at this and have no clue how to compare an data array to a field. Let alone read the values into the array.

View Replies!   View Related
Read Entire Row Into An Array
I have a workbook with about 700 rows and about 40 records on each row. about 2-7 a day of these.
The procedure I currently use a loop for does 2 different things.

1 I collect only a few of the records from the line and place them in a separate sheet .I collect the individual data, identify the ID ( cell F) and then search for the corresponding ID on a nother sheet when I do find it I add the info to the sheet on the last + next row. (I sort later)

2 I collect the entire row and place it on yet a nother sheet.
The whole row has information that is categorised by the content of Cell A (name) so I copy the row and paste it into a separate sheet.

What I would idealy like to do is to copy the entire source sheet into an array once, and then copy the data into each target sheet using a loop to get each record from the array. Using only 1 loop to first read the separate data from the " array row" and place it into the first target sheet (procedure 1) and then switch the workbook and copy the whole "array row" into the target sheet there (procedure 2).

At the moment I read info on 1 row switch to the target sheet and place the information there, then I "copy" the row and switch to the next workbook and paste it there then I go back to the source and do the next row.

Obviously Im no programer and that was the best way of doing what I didnt know how to do better .

Is there a way that a whole row can be stored in an array and then 'copied' onto another row on a nother sheet without reading in the individual cells into separate elements. That would be the worse case scenario but a much faster way of doing what I curently have.

View Replies!   View Related
ComboBox List To Read Values From An Array
How do I set a ComboBox list to read values from an array? I tried the following in VBA, but it didn't work....

ComboBox1.List = Array("January", "February", "March", “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”)

View Replies!   View Related
Passing A Range To Be Read As An Array To A Custom Function
code to pass a range say (A1:A3) as an arguement among other arguements to a custom function and then reading this as an array inside the custom funtion

View Replies!   View Related
Copy Array Formula To Other Cells Via VBA
{=AVERAGE(IF(('Sales Reports'!$A$1:$A$5000=$A3)*('Sales Reports'!$C$1:$C$5000=$C$1),'Break Reports'!$D$1:$F$5000))}

and am copying it to other cells using this
Sub copyformula()
With Sheets("Sheet2")
.Range("B3:B5000").Formula = .Range("B3").Formula
End With
End Sub
It does the copy but removes the { and } thus rendering the formula useless to me. How can I accomplish this task and keep the formula as an array formula?

I tried to drag the formula down and recorded it as a macro but when it runs it takes far to long.

View Replies!   View Related
Limitation On String Variables
I have recently come across a VBA macro, which reads from a text box within an excel input sheet, copy the text content, and send it via email. However, when the text content started to go beyond a certain number of characters, the text that comes out of the email, got truncated. I presumed this is something to do with the limitation to the string variables where the string " messagebody$ " which is used to read the text can only take up a certain bytes.

I was looking for VBA help, and somehow, it mentioned something called a variable-length string. Would that be a solution to my problem, or how is that used ?

ActiveSheet.Shapes("Rectangle 1").Select
messagebody = Selection.Characters.Text

email.Body = messagebody

View Replies!   View Related
Array Of Variables Want To Match Them
What would be the best approach/funcvtion to use in excel if I had an array of variables and wanted to match them?



I would like to lookup up a column and if either of these numbers are in that row to say "yes otherwise "No"

View Replies!   View Related
Splitting A Cell String Depending On Variables
On to what brought me here; I have a spreadsheet with a column containing an address, eg '12 SMITH ST SOMESUBURB NSW 2001'. I'm looking at splitting this cell in half after the street and moving the second half (suburb state postcode) into the next cell, which i've managed to do with a series on InStr statements.

Now the fun part is that not all these addresses are streets, some are avenues (AV or AVE), roads (RD), place (PL), drive (DR or DRV) etc. Initially i just did this:

View Replies!   View Related
Range Names Created From String Variables
I work with data that varies in row numbers but is consisten in column width. I am trying to write code that will create a named range for the data but be flexible to expand or contract based on the amount of data that is pulled in. Below is the

Const lngLastPossRow As Long = 65536
Dim strDataRng As String
strDataRng = ActiveSheet.Name & "!R4C1:R" & Range("a" & lngLastPossRow).End(xlUp).Row & "C17"
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
ActiveWorkbook.Names.Add Name:=("Data"), RefersToR1C1:= _

While the result creates a named range called "Data" , it does not allow me to reference and data in any formulas ( sumif's, etc). Can someone tell me what I am missing. It appears to be returning the wrong data type (string as opposed to range values).

View Replies!   View Related
Long Text String With Embedded Variables
I am trying to automate a report writing spreadsheet in which the text never changes in the cell (up to and over 50 words long).

Is there any way in which the figures within that text could be linked to another cell and change accordingly.

For example: a particular cell might contain the following which never changes apart from the figures:

"the performance of the fund was (B5) followed by a change in the index of (B6)...........the performance of the irish stocks was (A19) etc etc."

I know something can be done in formatting but for very long text would this be impracticle?

View Replies!   View Related
VBA Change Font Size Of A Character Or Letter Within Any String In Selected Cells
Looking for VBA that can change the font size of "•" char(0149) within any string in selected cells.

Also looking to delete the last "•" char(0149) within any string of selected cells.

What would the syntax for these two functions be?

View Replies!   View Related
Vlookup, 9 Different Variables, 9 Different Table Array
I need to be able to do a look up in 9 different table arrays using 9 different ranges.

I have attached a worksheet to help explain. My problem is that I can't have 9 IF statements in one formula.

I am not sure how to make this smaller or work.

View Replies!   View Related
Create Array Of Variables And Sort
I have a dynamic number of rows each with three colums of values. These varaibles I want to fill an array with but I don't know how.

Now I've just "concated" these three variables into a string and then I intend to split the string into rows by the third comma. (see below)

I think it's easier though to use an array and I really appreciate some assistance. Please tell me also the best way to sort the array. It will be sorted by var_Status which is an integer. (sort order: max positive to max minimum)

PreString = PreString & var_StartWeek & ", " & var_Status & ", " & var_Totalh & ", "

View Replies!   View Related
Variables To Contruct The Name Of The Active Array
I am trying to construct an indirect array reference as follows;

Dim A10 As Variant
Dim A11 As Variant
Dim A12 As Variant
For i = 0 To 2
String1 = "A" & (10 + i)
String1 = Cells(6, D1_CNum + i).Resize(2995, 1)

But the above doesn't work, what would be the correct way of creating a reference to an Array using variables to contruct the name of the active Array?

I was hoping String1 would equal "A10", so that on the Cells command Array A10, A11 and A12 would be filled using the value of String1??

View Replies!   View Related
Pass Array Variables Between Modules
I am trying to pass a public variable to another module in the same workbook. On Module1 I declare at the top

Public stores
Sub Main()
Dim stores(1 To 100, 1 To 10, 1 To 10)


...which then calls the procedure Reader in Module2

Sub Reader()
let x=1
let y=1
let z=1
let stores (x,y,z)=activecell.value

I've left out the portions of code that seem irrelevant. When the macro runs, I get a type mismatch error on the "let stores" line. If I move the code from Reader into the procedure Main, it works, so it seems to be an issue with passing the variable. I haven't used multiple modules very often so this is probably a very basic issue.

View Replies!   View Related
Use Variables In The FormulaText Argement Other Than String Values As Integers
I've a big problem getting the Constraints in excel solver to use variables.
It seems that the only accepted variable type in the contraints are STRING variables. THe following simple example works AS LONG AS the variable apa is a STRING value and as long as it doesn't contain decimals....

So the question is. How to use varialbes in the FormulaText argement other than string values as integers?

View Replies!   View Related
Subscript Out Of Range Using Public Array Variables
In my VBA project I've declared several public variables as normal (ahead of
all procedures) ... Public simolo() As double etc. They are declared in normal modules, and arent declared twice. I set the values in one procedure and then execute a second procedure but, when the variable is encountered in the second procedure, it appears to be empty and I get a "Subscript out of range" error. Clearly, the public variable isn't public since no data is stored in it.
What is going on?

View Replies!   View Related
Read Text File Using VBA
I know how to pull an entire text file
into an Excel Spreadsheet, but I only want specific information from
the text file not the entire text file.

What I have is about 25 text files stored in a folder, let's say
C: est.

Each file is named by a property address as follows:
209 MAIN ST.txt
213 MAIN ST.txt
111 ELM ST.txt
2356 WOOD AVE.txt

On the 11th row of each file is as follows:
Property Address:209 MAIN ST
On the 31st row of each file is as follows:
Total Value:30500

What I would like to do is read each file located in the "C: est
folder and write a record (row) into a single Excel Spreadsheet for
each property. I would like the Excel Spreadsheet to look as follows
once completed. Note the 1st row below is a header row that needs to
be generated by the code.

Property AddressTotal Value
209 MAIN ST 30500
213 MAIN ST 60700
111 ELM ST 20400
2356 WOOD AVE 20900

Can I read a header list (in a spreadsheet, text file, or hard coded in
the code) which I would prefer the spreadsheet or text file method,
write the header row in A1 then B1. Next read the 25 text files and
search based on the header info written above (Property Address & Total
Value) and write the appropriate to the single spreadsheet. The 11th
row of the First text file value written in cell A2, then read the 31st
row of the First text file write the value in cell B2, then loop to the
Second text file and values from The 11th row of the Second text file
value written in cell A3, then read the 31st row of the Second text
file write the value in cell B3, so on and so forth until the last text
file is read and the last record is written.

View Replies!   View Related
To Read A File And To Make Changes Using VBA
I have attached three excel files .....In the file called 'sampleBook1latest' I have a button called 'click here to clear a schedule' If I click that button and choose OR,start time and duration of a surgery then a schedule that is already created wil get cleared.....I have the total number of nurses and number of nurses used saved to the side of the sheet..... The total number of nurses at the side is read from another excel file called 'Input file for # of nurses'

Now the problem is that if clear a schedule then the number of nurses used is not getting updated at the side.....if I clear a schedule then the number of nurses at the side should also get updated....for example(If I create a schedule with 3 nurses and if only a total of 3 nurses are available then..... the used number of nurses for that specific time at the side will get updated to 3 from 0 and if I clear that schedule then the used nurses for that time should again become 0)....

The other problem is that if I schedule a surgery then all details of the surgery will be saved in another excel sheet called 'input file for patient details' so if I clear a schedule then all the details of that surgery saved in that excel sheet should also be cleared......

View Replies!   View Related
VBA Read Dates As Numbers?
I have a userform that has several textboxes and checkboxes. Some of the textboxes read and display dates from certain cells. I have the checkboxes conditionally formatted based on the data in the textboxes. However it doesn't seem to be reading the dates as a value. Here's an example of my issue to make it clear for you:

txtBox 1 = 01Sep2009
txtBox 2 = 01Oct2009

What I need is for the checkbox text colour to change from black to red if txtBox1 < txtBox2. Here's the code I have in place:

View Replies!   View Related
VBA To Read Full Dates Not Just The Day
I have a macro which searches for the latest date down a column and across particular rows. Extract of the code is shown below:

View Replies!   View Related
Read A Date Rather Than A Line VBA Macro
I have the following code which reads line 54 (row 54) in a spreadsheet and calculates the following using data in subsequent columns. Sometimes the data I need isn't always in row 54, I would rather have the macro read the data in Column A[AB] that is on line 54...sometimes on 53.

The date is Sep-09. How can I make it read this rather than AB54. I think I just need changes @ the top (ie Dim rng as Range, Set rng = [AB54]).

Sub Profile_info2()
Dim rng As Range
Set rng = [AB54]
rng.FormulaR1C1 = "=RC[-12]+R[-1]C[-12]+R[-2]C[-12]"
With rng.Offset(0, 2)
.FormulaR1C1 = "=((RC[-28]+R[-1]C[-28]+R[-2]C[-28])*4)/((RC[-25]+R[-1]C[-25]+R[-2]C[-25])/3)"
.NumberFormat = "0.0"
End With
With rng.Offset(0, 3)
.FormulaR1C1 = _
.Style = "Percent"
.NumberFormat = "0.0%"
End With
rng.Offset(0, 4).FormulaR1C1 = "=RC[-8]"
With rng.Offset(0, 5)
.FormulaR1C1 = "=(((RC[-17]-RC[-31])+(R[-1]C[-17]-R[-1]C[-31])+(R[-2]C[-17]-R[-2]C[-31]))*4)/((RC[-28]+R[-1]C[-28]+R[-2]C[-28])/3)"
.Style = "Percent"
End With
End Sub

View Replies!   View Related
VBA To Read Data From A Text File
I have written a VBA to read data from a text file (almost 5 MB = 2 lakh rows) and write into excel file. The script runs fine and transfers all data to the excel.But when i open the resulting excel file, only the first 2 and the last worksheets are visible. The worksheets in between and the data in it are missing. Second issue is tht, although i have written code to create a new worksheet when row number reaches 65535, the script writes only till row no. 32768.

View Replies!   View Related
Change VBA Text To Read As A Number
The code below is for a Userform to allow data to be entered into a form and than placed into a worksheet. Also this code allows me to edit the existing data in the worksheet and than place the data back into the worksheet when down editing.

The problem is some of the data in my userform are numbers and the userform is reading it as text. When I enter numbers into the userform and than place it into the worksheet, how can I change the code so that the userforms to recongnize numbers not a text?

Private Sub UserForm_Initialize()
With ActiveCell
If .Value = vbNullString Then
With .Parent
Set myCells = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0)
End With
Set myCells = ActiveCell.EntireRow.Range("A1")
End If
Set myCells = myCells.Resize(1, 28)
End With
Call FromSheetToUserform
End Sub

Sub FromSheetToUserform()
Dim myData As Variant

myData = Application.Transpose(Application.Transpose(myCells.Value))
If myData(1) = vbNullString Then myData(1) = Format(Date, "Medium Date")

With Me
.txtDATE.Text = CStr(myData(1))
.txtTYPE.Text = CStr(myData(2))
.txtIDENT.Text = CStr(myData(3))
.txtROUTE.Text = CStr(myData(4))
.txtTOTAL.Text = CStr(myData(5))
.txtSEL.Text = CStr(myData(6))
.txtSES.Text = CStr(myData(7))
.txtMEL.Text = CStr(myData(8))

View Replies!   View Related
Vba Cell() Text Read Limitation
I was sure it would be in your archives but couldn't find it - apologies if this is a FAQ.

I am trying to extract the data in a spreadsheet to a bunch of files, one file per cell. The cells I need have very long text strings in them, actually whole HTML files.

Using this

Dim HTML As String
HTML = Cells(RowNdx, ColNdx).text

I can only read 1024 bytes - not nearly enough. Is there something else I can do to read the cell into a string variable?

View Replies!   View Related
Array As String And Integer Together
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 Replies!   View Related
Split String Into Array
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 Replies!   View Related
Sort String Array
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 Replies!   View Related
Sum Array In VBA And Clearing An Array
1) after I have made an filled an array with data.
Dim orders(100000 To 200000) As Double
I want to then sum the orders above and below a number, lets say

View Replies!   View Related
Read Time Formatted Cell In VBA Macro
I've written a script to read all the values in an excel worksheet in to an array. The cell types differ from General or Text to Custom - HH:MM When I look through the array the script has returned the correct value for most but for the cells that are of a custom type an "incorrect" value has been returned. For example a cell of type Custom HH:MM which is 10:23:00 in the worksheet appears as 0.432638888888889 in the array. Is there a way to get the script to return the correct value?
Below is an extract of the code I've used

If objWorksheet.Cells(i, "D") <> "" Then
If objWorksheet.Cells(i, "F") <> "" Then
arrCULDEV = Split(objWorksheet.Cells(i, "F"), ":")
Redim Preserve arrSheetInfo(x)
arrSheetInfo(x) = arrCULDEV(0) & "," & arrCULDEV(1)
x = x + 1
i = i + 1
i = i + 1
End If
End If

View Replies!   View Related
Converting String To Byte Array
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 Replies!   View Related
Declare String As Array Index
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 Replies!   View Related
Array Formula Referencing A String
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.


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 >>" target="_blank"> Excel Jeanie HTML 4

View Replies!   View Related
Transpose And Split String Into An Array
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 Replies!   View Related
VBA Read/write .MP3 & .WMA Properties()
I have had a long-held belief that Excel/VBA methodology is very suited to solving this problem. I have investigated several possible methods noted below and picked one that gives a "quick win". I offer my results so far as a step towards the goal, as well as giving an example of how to manipulate a non-MS Office application using VBA. In this case Windows Explorer - I have used similar code on corporate applications like Oracle and SAP. My 'Write' method uses Sendkeys. Luckily I have been able to do the job without having to use code to simulate mouse functions or using API calls to simulate key presses. Ideally I would like to use something more stable, but there is the bonus that it is simple, as well as changing WMA and both versions of MP3 tag (see below) if present. Perhaps on reading this someone else may have a better method.

Being a ballroom dancer I have a large collection of CDs as well as software to rip to hard drive and enhance the sound quality. Many are quite old. A big problem has been to get a consistent view of the file properties - especially Genre, (eg. Waltz, Foxtrot .. etc.) which, from my own CD burning or external sources, is missing, or incorrect from using the now obsolete ID3v1 tag standard list. Applications such as Windows Media Player and RealPlayer allow functionality to edit tags but become very tiresome when it comes to making bulk changes - such as after burning a new CD. When viewing properties of the same file in various other applications they often show things like Title & Artist switched, and Genre not at all. I have tried software to change MP3 file tags, but find them over-complicated, confusing, and difficult to make the bulk changes I need. With Windows Explorer we can only change 8 properties - but I find these sufficient.

My method is :-

1. READ : Run one macro to put data into a worksheet.....

2. MAKE CHANGES : Make manual changes to the Excel worksheet in the normal way....

3. WRITE : Run another macro to read the worksheet and update the file properties in Explorer.

Part 1 is very simple and robust. Part 3 is difficult because when we use Sendkeys to mimic keyboard entry the code runs too fast to allow time for things to happen on screen, so we have to put Wait statements *depending on how fast the computer runs*. So Slower is better - up to a point.

Properties are added to MP3 files by using a "Tag" - additional bytes of information which form part of the file. WMA files are a Microsoft invention using a similar, but different structure. Interestingly, using my code to make changes via Window Explorer updates BOTH MP3 Tag versions as well as .WMA files. I moan about Microsoft less and less.

MP3 *ID3v1* consisting of 128 bytes always at the end of the file is now 'obsolete' - despite being still in use. This is very easy to read/write using the same code as for Text Files eg.

Open "c:myfile.mp3" For Binary As #1

etc. It is, however, limited to 4 text fields of 30 characters max, 'Year' =4 characters, and 'Genre' is a single character, the Asc() code of which is a lookup to a standard list which contains 125 items - none of which is any good to me. Could have my own lookup I suppose.

MP3 *ID3v2.3* is in the process of being superseded by ID3v2.4. The big problem here is that there are several different versions and the code required is extremely complicated - mainly due to the use of variable length fields. So we not only have to find the property, but read the field length before getting the field contents. Writing would need to change the coded field length. This is further complicated by there being the option to use an "Extended Tag" - *or not* ! Version 2 tag can be at the beginning or end of the file (before ID3v1 if it exists) - or both. The MP3 files on my computer all seem to have both versions - v2 at the beginning and v1 at the end. It is further complicated by the ability to have User Defined fields. I see some of my files have a user defined 'Genre' field, despite having the standard one 'TCON' too. The tag also needs a form of "encryption" so that the mp3 player does not treat it as audio data. Visit here for detailed information .

To view an audio file in its raw state open it in a Text Editor. I use 'TexPad' which is very fast and gives a choice of Binary (with Text 'translation' in a column) or Text view. Notepad gives just a Text view with empty space for non-text/binary characters. There is a large number of Null characters Asc(0) in proportion to the overall file length - mainly for "future development" I believe.

I would be interested to hear of any comments, suggestions and code improvements.


View Replies!   View Related
Covert Space Delimited String To Array
I have two columns of data, one for Position, and one for description.

The positions are concatenated and separated by spaces. E.g. C1 C2 C3 for each Description. I need to create a separate row for each position

So I need to convert:

Pos Decscription
C1 C2 C3 Cap 100n 10% X7R 0805


Pos Decscription
C1 Cap 100n 10% X7R 0805
C2 Cap 100n 10% X7R 0805
C3 Cap 100n 10% X7R 0805

Or in other words split a space delimited string into an array, so that I can loop through the array, and add new rows

View Replies!   View Related
Passing Array Of UDT With String To C++ Dll
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 Replies!   View Related
Extract Data From A String Array And Sum
I want to extract data from array string and then sum the values. For reference attaching the excel.

View Replies!   View Related
String Limit In Array - Querytables - Error 13
I need understanding what is the maximum length of string data type. I read that is 63K characters... but, in my case... maximum value is 253. I don't know why happens this. here is some code from one of my buttons.

Private Sub btn_procesare_Click()
Dim intUnit As Integer
Dim strBuffer As String
Dim contor, var_else, cale, dest, dest_final, masca, filtru, **** As String
Dim vntbuf As Variant
Dim sql As Variant
For i = 0 To Me.ListBox2.ListCount - 1
Application.Worksheets(1). Range("A" & i + 2).Value = Me.ListBox2.List(i, 0)

when watch for x, the value is maximum 253 characters. I get error Data Type Mismatch - Error 13 with this.

View Replies!   View Related
I've been trying to use IF OR and CONCATENATE to read 4 cells and give me a list of parts needed based on the data loaded in the 4 cells. I attached an example showing.

View Replies!   View Related
Read Times From Cells
Is it possible to create an individual variable time clock that is only useable by a specific workbook?

I have set up a calendar which has all days of the week in column 1, with start times in column 2 and end times in column 3. These times are adjustable on a daily basis.

Is it possible to create a macro that reads through the sheet and tells the workbook to disregard the system clock and use only the start and end times for each date stipulated in the table.

ie 7/9/06 has a start time of 6am and a finish of 6pm, not 0000 and 2400 as it would with the system clock?

View Replies!   View Related
Copyright © 2005-08, All rights reserved