copy paste special values with using VBA

%3CLINGO-SUB%20id%3D%22lingo-sub-2373361%22%20slang%3D%22en-US%22%3Ecopy%20paste%20special%20values%20with%20using%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2373361%22%20slang%3D%22en-US%22%3E%3CP%3EI%20see%20you%20can%20use%20VBA%20to%20copy%20the%20value%20of%20a%20formal.%20For%20those%20who%20don't%20know%20VBA%20can%20you%20do%20this%20using%20a%20formula.%20My%20goal%20is%20to%20use%20a%20worksheet%20template%20that%20when%20I%20insert%20a%20column%20of%20data%20into%20a%20cells%20it%20automatically%20separates%20the%20text%20from%20the%20number%20and%20sums%20the%20column%20of%20numbers.%3C%2FP%3E%3CP%3EData%3D%22US%20%24500%22%20I%20use%20this%20formula%20to%20separate%20the%20number%26nbsp%3B%3DRIGHT(H3%2CLEN(H3)-SEARCH(%22%20%22%2CH3)-1).%20But%20I%20need%20the%20end%20results%20to%20be%20just%20a%20number%20and%20not%20the%20result%20of%20a%20formula.%20I%20know%20how%20to%20manual%20copy%20and%20paste%20special%20but%20wanted%20it%20automatic.%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20would%20be%20appreciated.%3C%2FP%3E%3CP%3Ethanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2373361%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2373447%22%20slang%3D%22en-US%22%3ERe%3A%20copy%20paste%20special%20values%20with%20using%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2373447%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1059296%22%20target%3D%22_blank%22%3E%40excelnewbie1%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20is%20a%20macro%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3ESub%20ExtractAmounts()%0A%20%20%20%20Range(Range(%22A3%22)%2C%20Range(%22A3%22).End(xlDown)).TextToColumns%20_%0A%20%20%20%20%20%20%20%20Destination%3A%3DRange(%22B3%22)%2C%20_%0A%20%20%20%20%20%20%20%20Other%3A%3DTrue%2C%20OtherChar%3A%3D%22%24%22%2C%20_%0A%20%20%20%20%20%20%20%20FieldInfo%3A%3DArray(Array(1%2C%20xlSkipColumn)%2C%20Array(2%2C%20xlGeneralFormat))%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2374475%22%20slang%3D%22en-US%22%3ERe%3A%20copy%20paste%20special%20values%20with%20using%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2374475%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1059296%22%20target%3D%22_blank%22%3E%40excelnewbie1%3C%2FA%3E%26nbsp%3BAlternatively%2C%20use%20Text-to-columns%20on%20the%20Data%20ribbon.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1%3A%20Select%20the%20column%20with%20the%20amounts%20in%20a%20text%20format%3B%3C%2FP%3E%3CP%3E2%3A%20Data%2C%20Text-to-columns%3B%3C%2FP%3E%3CP%3E3%3A%20Step%201%20of%203%2C%20choose%20Delimited%2C%20press%20next%3B%3C%2FP%3E%3CP%3E4%3A%20Step%202%20of%203%2C%20in%20the%20preview%20window%2C%20select%20the%20first%20column%20and%20check%20the%20%22Do%20not%20import%20column%20(skip)%22%20button.%20Then%20select%20the%202nd%20column%2C%20check%20the%20%22General%22%20button%20and%20press%20%22Advanced...%22.%20Make%20sure%20that%20the%20comma%20is%20set%20as%20the%20thousand-separator.%20Press%20OK%2C%20Press%20Finish.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20should%20end%20up%20with%20one%20column%20of%20numbers.%20No%20formulae%20or%20VBA%20needed.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2375473%22%20slang%3D%22en-US%22%3ERe%3A%20copy%20paste%20special%20values%20with%20using%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2375473%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%20thanks%20I%20will%20give%20it%20a%20try.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I see you can use VBA to copy the value of a formal. For those who don't know VBA can you do this using a formula. My goal is to use a worksheet template that when I insert a column of data into a cells it automatically separates the text from the number and sums the column of numbers.

Data="US $500" I use this formula to separate the number =RIGHT(H3,LEN(H3)-SEARCH(" ",H3)-1). But I need the end results to be just a number and not the result of a formula. I know how to manual copy and paste special but wanted it automatic. 

Any help would be appreciated.

thanks

3 Replies

@excelnewbie1 

Here is a macro:

 

Sub ExtractAmounts()
    Range(Range("A3"), Range("A3").End(xlDown)).TextToColumns _
        Destination:=Range("B3"), _
        Other:=True, OtherChar:="$", _
        FieldInfo:=Array(Array(1, xlSkipColumn), Array(2, xlGeneralFormat))
End Sub

@excelnewbie1 Alternatively, use Text-to-columns on the Data ribbon.

 

1: Select the column with the amounts in a text format;

2: Data, Text-to-columns;

3: Step 1 of 3, choose Delimited, press next;

4: Step 2 of 3, in the preview window, select the first column and check the "Do not import column (skip)" button. Then select the 2nd column, check the "General" button and press "Advanced...". Make sure that the comma is set as the thousand-separator. Press OK, Press Finish.

 

You should end up with one column of numbers. No formulae or VBA needed.

@Hans Vogelaar  thanks I will give it a try.