Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Add Cells error

I'd add a couple of msgboxes to see the values of the cell and the counter:

msgbox k
msgbox cells(k,1).text
then maybe use:
v = Cells(k, 1).text 'v= Data Value




Gene Augustin wrote:

MAC Powerbook G4, OS 10.5.6
Office 2004, Excel 2004 Version 11.5.3

In a macro,I have assigned values:
i = 1
j = 1
v = D02/28/2008
shtnew = Sheets("IIF")

The following gives runtime error 91, although it works in another macro
with identical definitions.

shtnew.Cells(i, colnum).Value = v

Here is the entire macro

Sub QifTo8Col()
Dim Shtcount As Long, v As String
Dim shtold As Worksheet, shtnew As Worksheet
Dim colID As String, coldet As Long, colnum As Long
'Rename and add sheet
Shtcount = Sheets.Count

Sheets(1).Name = "QIF"
Set shtold = Sheets("QIF")
If Shtcount = 1 Then
Sheets.Add after:=Sheets(Sheets.Count)
Sheets(2).Name = "IIF"
Set shtnew = Sheets("IIF")
'Else

End If

shtold.Activate
n = Cells(Rows.Count, 1).End(xlUp).Row

coldet = 0 'identify missing columns C N M

i = 1 ' new row number
j = 0 ' new column number from 1 to between 5 and 7

For k = 1 To n 'For this row in raw data
v = Cells(k, 1) 'v= Data Value
If v < "^" Then 'part of a group,
colexp = 0
colID = Left(v, 1) 'D, T, C, N, P, M, L, ^

Select Case colID
Case "D"
j = 1
'ColExp= 0
Case "T"
j = 2
'ColExp= 1
Case "C"
j = 3
'ColExp= 2
Case "N"
j = 4
Case "P"
j = 5
Case "M"
j = 6
Case "L"
j = 7


' Case Else

End Select

colexp = j - 1
coldet = coldet + 2 ^ colexp

shtnew.Cells(i, j).Value = v



' j = j + 1
Else

coldet = 127 - coldet

Select Case coldet
Case 123 'no C
Sht.newCells(i, 3) = "CX"

Case 119 'No N
Sht.newCells(i, 4) = "N"

Case 95 'No M
Sht.newCells(i, 6) = "MNo Memo"

Case 115 'No CN
Sht.newCells(i, 3) = "CX"
Sht.newCells(i, 4) = "N"

Case 91 'No CM
Sht.newCells(i, 3) = "CX"
Sht.newCells(i, 6) = "MNo Memo"

Case 83 'No CNM
Sht.newCells(i, 3) = "CX"
Sht.newCells(i, 4) = "N"
Sht.newCells(i, 6) = "MNo Memo"

Case 87 'No NM
Sht.newCells(i, 4) = "N"
Sht.newCells(i, 6) = "MNo Memo"

End Select
coldet = 0
i = i + 1
j = 0
End If
Next

End Sub


--

Dave Peterson
 
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
zero value cells/blank cells causing error in AVERAGE? LilBeanie1033 Excel Worksheet Functions 5 March 19th 09 06:39 PM
Sum ignoring cells with error JRD Excel Worksheet Functions 1 December 12th 07 05:27 PM
Set RN = Range(Cells(2, 1), Cells(r, 1)) error Daniel Charts and Charting in Excel 3 June 17th 07 08:30 PM
Cells(x,y) error fmistry Excel Discussion (Misc queries) 12 April 17th 07 11:21 PM
Hiding Error in Cells!! slvtenn Excel Discussion (Misc queries) 4 March 6th 06 02:06 AM


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

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

About Us

"It's about Microsoft Excel"