Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 11th, 2006, 04:56 AM
Authorized User
 
Join Date: Sep 2006
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copy only numeric value from one colum

Hi is it possible to copy only the numeric value from one colum to another colum in the same table?

Example:

Sub ABILIFY10()
    Selection.Font.Bold = True
    Selection.TypeText Text:="(ABILIFY 10 MG - CXS. 28 COMP.)"
    Selection.TypeParagraph
    Selection.TypeText Text:="Preço/comp.: "
    Selection.Font.Bold = False
    Selection.TypeText Text:=" CINCO VIRGULA ZERO TRÊS UM SETE OITO SEIS EUROS + IVA…………………………………."
    Selection.Font.Size = 6
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.Font.Size = 12
    Selection.Font.Bold = False
    Selection.TypeText Text:="N.º Reg. INFARMED: 5056387"
    Selection.TypeParagraph
End Sub

I want to copy Selection.TypeText Text:="N.º Reg. INFARMED: 5056387"
only the numeric value of this cell (5056387) to another cell in the same table.


 
Old October 16th, 2006, 08:26 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

If there is always ": " after 'INFARMED' you could use the following simple method to extract the number from the string:

Sub strTest()

myStr = "N.º Reg. INFARMED: 5038756"
getStr = Mid(myStr, InStr(myStr, ": ") + 2)

Debug.Print getStr


End Sub

HTH!
Cheers
Joe

'sync' <cr>
The name specified is not recognized as an internal or external command, operable program or batch file.
 
Old October 16th, 2006, 08:31 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

If the text like '"N.º Reg. INFARMED: 5056387"'
does not contain any other number other than what you expect (5056387)
you can use regular expressions to pull out the number alone.

Cheers:)
Shasur

http://www.vbadud.blogspot.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
From numeric to alfa numeric ebekir XSLT 1 August 10th, 2007 06:13 AM
Multi Colum Listbox JAdkins Classic ASP Basics 3 July 9th, 2007 01:40 AM
table colum break mateenmohd Classic ASP Basics 0 May 25th, 2007 10:10 AM
Copy only numeric value from one colum hugoscp Word VBA 1 November 22nd, 2006 10:56 AM
Loading a dropdown from a datagrid colum brenclarke VB.NET 2002/2003 Basics 1 May 30th, 2004 08:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.