Basic Macro - Convert String To Unicode

Mar 30, 2014

The following macro works:

Code:
Range("b42").Resize(, Len(Range("A42").Value)) = split(StrConv(Range("A42").Value, vbUnicode), Chr(0))

I tried to revise the macro so that instead of 'b42' it's activecell.

Code:
Dim b As Range
Set b = ActiveCell
Range(b).Resize(, Len(Range(b).Value)) = split(StrConv(Range(b).Value, vbUnicode), Chr(0))

My code isn't working.

View 2 Replies


ADVERTISEMENT

Treating String As Array And Correct Array Format For Unicode Characters?

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

Basic Macro For Copying 2 Columns From One Workbook To Another

Apr 7, 2014

I have a basic question for a macro, I've looked at other threads but they all seem to have some kind of twist to it. All I want is a macro that copies columns A&B from a source workbook to my destination workbook in a specific worksheet for column A&B too. I'm assuming that the destination worksheet will automatically update whenever the source workbook is updated? My source workbook is called Job List 7 and the worksheet is called Master Job List, my destination is Ted's Timesheet and the sheet is called Job List.

View 10 Replies View Related

Macro Not Working While Visual Basic Is Open?

May 1, 2013

I have been running a macro on a continuous loop to collect data for months. Yesterday I added something small to the macro and now it does not select cells. I tried closing excel, opening a new page and have a simple macro

Sub Please_Work ()
Range('A4').Select
End Sub

If I have VBA open and step through it (F8), it does NOT work. If I run the sub (play button), it does NOT work. If I close VBA, and run the macro it DOES work.

View 9 Replies View Related

Send Email Through Macro Visual Basic?

Sep 21, 2013

macro visual basic and trying to do a simple report wherein i can send an email auto matically.

View 2 Replies View Related

Visual Basic Auto Filter Macro

Nov 19, 2007

I have a excel file that was created by someone else 7 years ago - I still want the formulas that were created but I have updated the information on the spreadsheet and now the macro will not work

Sub DataSort01()
'
' DataSort01 Macro
' Macro recorded 11/18/00 by Terry Schiesser
'
' Keyboard Shortcut: Ctrl+t
'
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:=">0", Operator:=xlAnd
End Sub

when I do the ctrl+t it wants to debug I select the debug option and then it goes to the screen above but the "Selection.Autofilter" is highlighted.

View 9 Replies View Related

Using VBA Code In Visual Basic: Develop A Stand Alone Program In Visual Basic

Jun 3, 2006

I would like to do is develop a stand alone program in Visual Basic ( not in Excel VBA) to update the price file in our Portfolio system automatically using the downloaded Excel format file csv extention file from the BigCharts. But before that, I need to export the *.pri file from our Portfolio system in to Excel which still saves as *.pri extention. Then once it updates, I import the updated *.pri file back in our Portfolio program. I understand that the Excel VBA code can be incorporated in Visual Basic code provided there is an object declaration for Excel file (In this case eventhough the both files are in Excel format, they don't have xls extention). how to use external files and Excel VBA code in Visual Basic?

Below is the code that I currently have in Visual Basic. What I'm trying to accomplish is using the ticker (eg. msft) as a keyword search to look up in the price file. If found , the price of that ticker from the test.csv file will be copied in to the price file which is test.pri. I haven't ran it yet.

Sub UpdatePrice(BigChartPath As String, BigChartName As String, AxysPricePath As String, AxysPriceName As String)
'Below are Excel VBA codes
'Uses the test.csv to look up tickers in test.pri and update the price in it
Dim PriceFile As Workbook, BigChartFile As Workbook
Dim PriceFileSheet As Worksheet, BigChartSheet As Worksheet
Dim MaxRows As Long
Dim PriceFileRow As Long
Dim BigChartRow As Long
Dim BigChartFound As Boolean
Call CheckBookOpen(BigChartPath & BigChartName)
Call CheckBookOpen(AxysPricePath & AxysPriceName)
Set BigChartFile = Workbooks(BigChartName) 'Big Chart website imported CSV file saved as test.csv...............

View 5 Replies View Related

Basic Find / Replace And Format Change Macro

Jun 26, 2013

how to write macros. Here is what i need:

-I need the macro to only search within column "B"

-There is both a date and time within the cell, the time is always " 00:00:00" and I need it to be replaced with blank/ ""

- The date is represented "1/1/2013" and i need the "/" to be turned into "-"

- and i need the number format to be changed to a custom format of "m-d-yyyy"

View 1 Replies View Related

Macro Has Errors If Visual Basic Editor Is Not Open

Nov 12, 2009

I've been helping another user create a workbook that dynamically adds, renames and deletes worksheets from a "Main Sheet".

I have got the whole thing figured out and running to satisfaction, except...

The macro runs fine if the Visual Basic Editor is open. If the editor is closed while the macro is run, I get "Runtime Error '9': Subscript out of range"

Any ideas what could be casing this? The errors occur when attempting to add sheets.

View 2 Replies View Related

Visual Basic Editor - Creating Macro Prompts

Apr 26, 2007

I have created macros before, but it was a step by step, easy to follow, guide from out textbook. Now I have to create one on my own from these directions.

So my first task was to create a macro that went to a specific worksheet, and made A1 the active cell. I created that macro.

Now it comes to where I have to open the macro in Visual Basic Editor and I am completely lost. I know absolutely nothing about this. This is what it looks like now:

Sub Show_Report()
'
' Show_Report Macro
' Macro recorded 4/25/2007 by *******
'
' Keyboard Shortcut: Ctrl+w
'
Sheets("Jeff").Select
Range("A1").Select
End Sub

So now these are the next directions. "Edit the Show_Report macro in the VBE so that the macro prompts the user for the name of the report to view (indicating that the user should enter "Jeff", "Sally", "Jane", "Jim", and "Harry") and then displays that worksheet. (HINT: You should run the edited macro to make sure that it runs correctly.) Include an If-Then-Else control structure to detect an error if the user enters an incorrect report name. If an error occurs, the macro should display a message box informing the user of the error.

So what Im thinking is I need a code so what when I hit my macro hotkey, it opens up a pop-up box and then I get to type in a worksheet name and it takes me to that worksheet.

View 9 Replies View Related

UDF To Convert String To Abbreviation?

Mar 18, 2013

I would like to have a UDF to convert any text string to an abbreviation. For example, "Del Puerto Creek at HWY" would be converted to DPCAH. Or "this text string" would be converted to TTS. This has to work on any string of any length in any cell. I guess the UDF would pass each character through a loop and extract the letter immediately after a space and capitalize the letter if it is not already in uppercase. The UDF would have to have the ability to drag using relative references. For example: =AbbrevTxt(A1). It does not matter what the UDF is named.

View 3 Replies View Related

Convert String To Date

Aug 2, 2013

I have a field in the format of 121031. I need a formula to convert this field to a date DD/MM/YYYY format, so 121031 becomes 31/10/2012.

View 9 Replies View Related

Convert String Value Into Range

Mar 27, 2009

I have a string variable (myCell) that contains a cell address (i.e. $A$66)

I have a Range variable (mrR1) that I want to give that value to.

I cannot figure out how to do it. Can anyone help?

After that, I'm hoping to use the Range variables in a Goal Seek.

Private Sub CommandButton1_Click()

Dim myMatch As Double
Dim myCell As String
Dim myStart As Range
Dim myIRR As String
Dim myR1 As Range
Dim myR2 As Range

myMatch = WorksheetFunction.Match(0.25, Range("K67:DZ67"))
myCell = Range("HurdleStart").Offset(0, myMatch).Address
myIRR = Range("IRRStart").Offset(0, myMatch).Address

' myR1 = myIRR value
' myR2 = myCell value

Range(myR1).GoalSeek Goal:=0.25, ChangingCell:=Range(myR2)

End Sub

View 9 Replies View Related

Convert A String To A Range

Apr 1, 2009

I'm working in Excel 2003. Is there a way to convert strings to Ranges on the Excel commandline?

I have a lookup function in an estimate sheet that uses 2 ranges, stored as strings, in another worksheet. They are used to return a price from another workbook. When I use named ranges to access them with the lookup function, it doesn't work. But when I cut and paste the strings into the commandline it works prefectly?


$A10 = Part Number to search for

MaterialOptions is a named Range
eg: '[Catalog.xls]PriceList'!$A$13:$A$17

PriceOptions is a named Range
eg: '[Catalog.xls]PriceList'!$Z$13:$Z$17

LOOKUP($A10,MaterialOptions,PriceOptions) = #VALUE!
But...
LOOKUP($A10,'[Catalog.xls]PriceList'!$A$13:$A$17,'[Catalog.xls]PriceList'!$Z$13:$Z$17) = Success!

View 9 Replies View Related

Counting BlackCircle Unicode Symbols

Feb 18, 2009

I use dot symbols in one column of my spreadsheet to call attention to a particular row. I am currently using ASCII(decimal) Char 149 and I count the column of dots with the following formula: =COUNTIF(A1:A20,CHAR(149))

This works fine, however, ASCII(decimal) Char 149 is a very small dot which is hard to see. I have found a much larger dot which is identified as BlackCircle Unicode(hex) 25CF. From an appearance standpoint the BlackCircle is much larger and much easier to see, however, I have been unable to construct a formula which will count the dots. How do I identify BlackCircle Unicode(hex) 25CF in order to count the character using the formula listed below: =COUNTIF(A165:A184,CHAR(25CF))

View 2 Replies View Related

Opening Unicode CSV File Using Opentext

Jul 7, 2012

I have written code to export data from excel as a unicode .csv file - see [URL] .....

However I now want to open that file by vba, yet it does not format the data correctly. I have a field in the delimited data that is string (in my .csv file strings are surrounded by " to indicate strings). This string can contain a vbLf as part of the string ie. the string goes over a couple of lines in one cell.

Using vba I open the .csv file as follows:

Code:
Workbooks.OpenText filename:=singlefname, origin:=65001, DataType:=xlDelimited, textqualifier:=xlTextQualifierDoubleQuote, comma:=True

yet when the code opens the file the vbLf starts a new worksheet row messing up the layout of the .csv file. It should just indicate a new line in a cell.

How to open the file so the vbLf only creates new line in the cell does not start a new worksheet row?

View 8 Replies View Related

Save As Text With Unicode And Tab Delimited

Oct 11, 2008

In my excel file I have chinese and some other special characters and many cells have text with commas.

My problem starts when I try to save my file as a Text.

When I Save As with the Unicode option I can see the chinese characters in my text file but also I see a lot of quotes """ because I have commas in my xls file.

When I Save As with Tab Delimited option to solve the comma problem, the chinese characters become?

It seems that cannot be possible to do it manually cause there is no option to Save As with Unicode and Tab option together.

So I would deeply appreciate someone could give me a solution with VBA code to save my file as Text with Unicode and Tab Delimited option.

View 9 Replies View Related

String Of Dates Convert To From And To Date

Mar 12, 2014

I have a spreadsheet with reference relating to dates that are listed as single days. I am trying to convert the single dates relating to a reference to a from and to date but i'm having problems.

Example

048051_14110/09/2013
048051_14111/09/2013
048051_14112/09/2013
048051_14113/09/2013
041929_14115/10/2013
041929_14116/10/2013
041929_14117/10/2013
041929_14118/10/2013

I want this to read

048051_141from - 10/09/2013 - to - 13/09/2013
041929_141from - 15/10/2013 - to -18/10/2013

View 1 Replies View Related

Convert Text String To A Date?

Aug 23, 2009

My database has 6 fields names and I have created the following code to capture and post data to the database form a userform. It works but I am sure there is a more efficient and elegant way to do this. The two areas I would like advice are:
1. converting the date string to a date.
2. the line of code where I subtract line6 from line4.

View 3 Replies View Related

Convert String Number To Date?

May 3, 2013

The following function reads many worksheets in one workbook and put the information into one worksheet. F22 to Q22 is dates in the format of mmm-yy on the many worksheets. On the one worksheet B1, C1, D1, etc... is dates also formatted mmm-yy. Now the many sheets only have a 12 month period but could be any date within 60 months. In the many worksheets the beginning date in F22 is based on the date that is entered into G8 of the many worksheets. The function is:

Code:
Function HrsByMonth(strField As String, MonthNum As Integer) As Long
Dim sht As Worksheet, i As Long, j As Integer
HrsByMonth = 0

[Code].....

View 6 Replies View Related

Convert Text String To Integer

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

Convert String To Object Or Function

Apr 11, 2007

I do not know if this is possible in VBA, but I am hoping it is as it will make my life much easier.

Is it possible to say have a TextBox and a CommandButton, that does the following?

Public Sub Execute()

Dim ObjectName As String
Dim Object As Object

ObjectName = txtObject.Text
Set Object = ObjectName

Object.Execute

End Sub

Or to take it a step further:

Public Sub Execute()

Dim ObjectName As String
Dim FunctionName As String
Dim Object As Object

ObjectName = txtObject.Text
FunctionName = txtFunction.Text
Set Object = ObjectName

Object.FunctionName

End Sub

Are there any inbuilt functions that will create/reference an object based on a string containing the name of the object or function?

View 9 Replies View Related

Convert Number String To Date

Dec 18, 2009

I am trying to convert a number string date that has been stored in a database to a readable date time in an excel pivot table.

1260983366 needs to look like Wednesday, December 16, 2009, 10:09 AM.

The converted date could also look like Wed, Dec 16, 09, 10:09 AM.

View 9 Replies View Related

Function That Shows The Unicode Code Of A Character

Oct 16, 2009

Does such function exist in Excel?

View 9 Replies View Related

Convert A String To A "real" String (vba)

May 18, 2007

How can any string valid for the name of a workbook be converted to a string correctly recognized by Application.Run? Sometimes a string is not really recognized as a string. See for example: .....

View 9 Replies View Related

Extract The First 5 Characters In A String, And Convert Them To A Number

Nov 7, 2008

Say I have a string "09800EBHR052708"

How would I take the first 5 characters and get a number out of them?

View 14 Replies View Related

Shorten String And Convert To Upper Case?

Mar 7, 2013

I got a list of counties in Texas, but the list is in mixed case and always has a " County" after each one. I got it converting to upper case, and have tried removing the " County" but no luck. Below is the code I have:

Code:
Sub TEXAS()
For a = 1 To 254
R = "D" & a
i = "a" & a
ActiveSheet.Range(R) = UCase(ActiveSheet.Range(i))
Next a
End Sub

View 7 Replies View Related

Convert Text String Into Excel Date With VBA

Aug 13, 2013

I have a date range that looks like this (British date style, not US):

edit: I posted an image but it can't be seen for some reason:

Date Range
2010 11/10 17/10
2010 11/10 17/10
2010 11/10 17/10
2010 11/10 17/10

Thus the first cell show 11 October 2010 to 17 October 2010 I want to return just the first day (the week commencing date):

edit: I posted an image but it can't be seen for some reason:

Week Commencing
11/10/2010
11/10/2010
11/10/2010
11/10/2010

I have written some VBA to the best of my ability but it seems clumsy using the FORMAT function. Is there a better of doing this with VBA. I can't seem to find a function in VBA which is the equivalent of the formula function DATE.

Code:
Sub ConvertTextToBritStyleDate()
' dd/mm/yyyy (not mm/dd/yyyy)
' Select the cells containing the dates (not the header)

[Code]...

View 3 Replies View Related

Using VBA Codes To Generate Consecutive Numbers And Convert Them Into String

Jan 10, 2013

If n = 5, then I want to generate a string like this: "1+2+3+4+5". Similarly, if n = 7, I want the string "1+2+3+4+5+6+7".

I can generate the consecutive numbers, but have not figured out how to generate the required string.

View 5 Replies View Related

How To Convert String To Excel Date Format Using Formula Or VBA

Sep 28, 2012

Is there a way to convert the string "Sep 28 2012" to excel date format using a formula or vba?

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved