ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating Macro/Formula (https://www.excelbanter.com/excel-programming/383590-creating-macro-formula.html)

Diana

Creating Macro/Formula
 
I have a table such as the one below, I would like to create a formula/macro
that will give my worksheet a comand to replace the text values on the left
with the numbers to their right. Is that possible??


ir 660
250
350
700
ar 987
320
710

Your help is very much appreciated

Gary''s Student

Creating Macro/Formula
 
Try something like:

Sub diane()
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To lastrow
If Application.WorksheetFunction.IsNumber(Cells(i, 1).Value) Then
Else
Cells(i, 1).Value = Cells(i, 2).Value
End If
Next
End Sub

--
Gary''s Student
gsnu200707


"Diana" wrote:

I have a table such as the one below, I would like to create a formula/macro
that will give my worksheet a comand to replace the text values on the left
with the numbers to their right. Is that possible??


ir 660
250
350
700
ar 987
320
710

Your help is very much appreciated


Max

Creating Macro/Formula
 
One formulas way ..
Assuming source data in cols A and B, from row1 down
In C1: =IF(A1="","",IF(ISTEXT(A1),B1,A1))
Copy C1 down, then copy col C & do a paste special as values to overwrite
col A. Clean up by deleting cols B and C
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Diana" wrote:
I have a table such as the one below, I would like to create a formula/macro
that will give my worksheet a comand to replace the text values on the left
with the numbers to their right. Is that possible??


ir 660
250
350
700
ar 987
320
710

Your help is very much appreciated



All times are GMT +1. The time now is 02:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com