Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Code logic error

Hi all

I must have a code logic error
I receive no errors at run-time
But I also don't receive any results

Code below
Drop me an e-mail if you would like the book with code
Remove nothere
Add .yah... (you know the rest)

Thanks
-goss


'Evaluate the cell
'If numeric, do nothing,
'Otherwise return only left 2 characters to the cell
'''''''''''''''''''''''''''''''
'Get_Rows is UDF
With wsData
For Each C In Range("B1:B" & Get_Rows)
If IsNumeric(C) Then
C = C * 1
Else
C = Left(C, 2)
End If
Next C
End With
''''''''''''''''''''''''''''''''''''''

'Evaluate for inner string
'If true concatenate with adjacent cell
'Return result to original cell
''''''''''''''''''''''''''''''''
'lngRows = Get_Rows
Do While lngRows = 1
For Each C In aRng
If InStr(C, "07-01") = 1 Then
C = C & Cells(lngRows, 2)
'C = Concatenate(C, Cells(Get_Rows, 2)) 'Tried First
Else
C = 0
End If
Next C
lngRows = lngRows - 1
Loop
'''''''''''''''''''''''''''''''''''''

Full Code:
'''''''''''''''''''''''''''''''''''''
Sub dewr_GetUnitNumbers()
'Get_Rows is UDF
'Globals : wbBook, wsData, wsFormulas, wsHeader, rnFormula
Dim aRng As Range
Dim lngRows As Long

Set wbBook = ThisWorkbook

With wbBook
Set wsData = .Worksheets("Data")
Set wsFormulas = .Worksheets("Formulas")
End With

With wsFormulas
Set rnFormula = .Range("A1:B1")
End With

With wsData
.Range("A1:B1").EntireColumn.Insert
.Range("A1:B" & Get_Rows).Formula = rnFormula.Formula
.Range("A1:B" & Get_Rows).Copy
.Range("A1:B" & Get_Rows).PasteSpecial
xlPasteValuesAndNumberFormats
.Range("A1:B" & Get_Rows).PasteSpecial xlPasteFormats
.Range ("A1")
End With

With wsData
For Each C In Range("B1:B" & Get_Rows)
If IsNumeric(C) Then
C = C * 1
Else
C = Left(C, 2)
End If
Next C
End With

With wsData
Set aRng = .Range("A1:A" & Get_Rows)
End With

lngRows = Get_Rows

Do While lngRows = 1
For Each C In aRng
If InStr(C, "07-01") = 1 Then
C = C & Cells(lngRows, 2)
'C = Concatenate(C, Cells(Get_Rows, 2)) 'Tried First
Else
C = 0
End If
Next C
lngRows = lngRows - 1
Loop

'Tidy up
Set wbBook = Nothing
Set wsData = Nothing
Set wsFormulas = Nothing
Set rnFormula = Nothing

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 611
Default Code logic error

Goss,

The first routine seems to work. This is what I tried:

'Evaluate the cell
'If numeric, do nothing,
'Otherwise return only left 2 characters to the cell
'''''''''''''''''''''''''''''''
'Get_Rows is UDF

Dim c As Range
Dim wsData As Object

With wsData ' unnecessary -- not used
For Each c In Range("B1:B" & Get_Rows) '
If IsNumeric(c) Then
Else
c = Left(c, 2)
End If
Next c
End With
''''''''''''''''''''''''''''''''''''''

Function Get_Rows() As Integer
Get_Rows = 5
End Function

Or you could write:
If Not IsNumeric(C) Then C = Left(C, 2)

--
Earl Kiosterud
www.smokeylake.com


wrote in message
oups.com...
Hi all

I must have a code logic error
I receive no errors at run-time
But I also don't receive any results

Code below
Drop me an e-mail if you would like the book with code
Remove nothere
Add .yah... (you know the rest)

Thanks
-goss


'Evaluate the cell
'If numeric, do nothing,
'Otherwise return only left 2 characters to the cell
'''''''''''''''''''''''''''''''
'Get_Rows is UDF
With wsData
For Each C In Range("B1:B" & Get_Rows)
If IsNumeric(C) Then
C = C * 1
Else
C = Left(C, 2)
End If
Next C
End With
''''''''''''''''''''''''''''''''''''''

'Evaluate for inner string
'If true concatenate with adjacent cell
'Return result to original cell
''''''''''''''''''''''''''''''''
'lngRows = Get_Rows
Do While lngRows = 1
For Each C In aRng
If InStr(C, "07-01") = 1 Then
C = C & Cells(lngRows, 2)
'C = Concatenate(C, Cells(Get_Rows, 2)) 'Tried First
Else
C = 0
End If
Next C
lngRows = lngRows - 1
Loop
'''''''''''''''''''''''''''''''''''''

Full Code:
'''''''''''''''''''''''''''''''''''''
Sub dewr_GetUnitNumbers()
'Get_Rows is UDF
'Globals : wbBook, wsData, wsFormulas, wsHeader, rnFormula
Dim aRng As Range
Dim lngRows As Long

Set wbBook = ThisWorkbook

With wbBook
Set wsData = .Worksheets("Data")
Set wsFormulas = .Worksheets("Formulas")
End With

With wsFormulas
Set rnFormula = .Range("A1:B1")
End With

With wsData
.Range("A1:B1").EntireColumn.Insert
.Range("A1:B" & Get_Rows).Formula = rnFormula.Formula
.Range("A1:B" & Get_Rows).Copy
.Range("A1:B" & Get_Rows).PasteSpecial
xlPasteValuesAndNumberFormats
.Range("A1:B" & Get_Rows).PasteSpecial xlPasteFormats
.Range ("A1")
End With

With wsData
For Each C In Range("B1:B" & Get_Rows)
If IsNumeric(C) Then
C = C * 1
Else
C = Left(C, 2)
End If
Next C
End With

With wsData
Set aRng = .Range("A1:A" & Get_Rows)
End With

lngRows = Get_Rows

Do While lngRows = 1
For Each C In aRng
If InStr(C, "07-01") = 1 Then
C = C & Cells(lngRows, 2)
'C = Concatenate(C, Cells(Get_Rows, 2)) 'Tried First
Else
C = 0
End If
Next C
lngRows = lngRows - 1
Loop

'Tidy up
Set wbBook = Nothing
Set wsData = Nothing
Set wsFormulas = Nothing
Set rnFormula = Nothing

End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there is a 90% chance of a logic error per 150 lines per workbo Jay Excel Discussion (Misc queries) 3 April 9th 09 06:03 PM
Code error ?? Anthony Excel Discussion (Misc queries) 2 February 9th 05 10:31 PM
How can I still go to the error-code after a On Error Goto? Michel[_3_] Excel Programming 2 May 4th 04 04:21 AM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM
can't find error in macro logic... tehwa[_6_] Excel Programming 7 January 15th 04 06:27 AM


All times are GMT +1. The time now is 06:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"