Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The following code steps through a range, tests an extracted value, and
either deletes the row or writes the test value in column 1 as a text value. For r = lastrow To 8 Step -1 tst = Left(impt.Cells(r, 2), 9) If Application.CountA(Rows(r)) = 0 Or IsNumeric(tst) = False Then Rows(r).Delete Else impt.Cells(r, 1) = WorksheetFunction.Text(tst, 0) End If Next r The problem is that the values written to the cells reference "cells(r,1)" is a numberic value, not text. (The str() function gives the same result.) I can achieve my objective if I run a new for...next loop on the extracted values after the above routine has completed, but why is that necesssary? Why will the conversion function not work as intended in the first loop? DM |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dick,
impt.Cells(r, 1) = "'" & Format(tst, "0") HTH, Bernie MS Excel MVP "Dick Minter" wrote in message ... The following code steps through a range, tests an extracted value, and either deletes the row or writes the test value in column 1 as a text value. For r = lastrow To 8 Step -1 tst = Left(impt.Cells(r, 2), 9) If Application.CountA(Rows(r)) = 0 Or IsNumeric(tst) = False Then Rows(r).Delete Else impt.Cells(r, 1) = WorksheetFunction.Text(tst, 0) End If Next r The problem is that the values written to the cells reference "cells(r,1)" is a numberic value, not text. (The str() function gives the same result.) I can achieve my objective if I run a new for...next loop on the extracted values after the above routine has completed, but why is that necesssary? Why will the conversion function not work as intended in the first loop? DM |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is column 1 formatted as text or something else. You may be getting an
implicit conversion when the value is dropped into the cell. Try formatting the column to text proir to running the macro and see if that helps. -- HTH... Jim Thomlinson "Dick Minter" wrote: The following code steps through a range, tests an extracted value, and either deletes the row or writes the test value in column 1 as a text value. For r = lastrow To 8 Step -1 tst = Left(impt.Cells(r, 2), 9) If Application.CountA(Rows(r)) = 0 Or IsNumeric(tst) = False Then Rows(r).Delete Else impt.Cells(r, 1) = WorksheetFunction.Text(tst, 0) End If Next r The problem is that the values written to the cells reference "cells(r,1)" is a numberic value, not text. (The str() function gives the same result.) I can achieve my objective if I run a new for...next loop on the extracted values after the above routine has completed, but why is that necesssary? Why will the conversion function not work as intended in the first loop? DM |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Problem in Conversion of Excel to Text(Tab delimated) | Excel Discussion (Misc queries) | |||
Timing Conversion problem | Excel Discussion (Misc queries) | |||
Conversion problem | Excel Discussion (Misc queries) | |||
Problem in Conversion | Excel Discussion (Misc queries) | |||
Excel Text Conversion Problem | Excel Discussion (Misc queries) |