LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Yet another error

This program formats and cleans up data coming in from SPSS (Statistics
software). It calls a couple of other programs. When it calls Change
Header, it hangs on the line noted below. Both variable are declared,
wkbData as a public workbook, rTtl as a public range. Both are set. So
why am I getting an "Application defined or object defined error at the
indicated line?


Option Explicit
Public wbkData As Workbook
Public rFoundHd As Range
Public rTtl As Range
Sub SPSSClean()
Dim myCell As Range
Dim CurCol As Range
Dim FoundCell As Range


Application.ScreenUpdating = False
Range("a1").Select
Selection.CurrentRegion.Select

Clean

'Change from SPSS headers to understandable headers
ChngHeader

Range("a1").Select

Set rTtl = Range(Selection, Selection.End(xlToRight))

For Each rFoundHd In rTtl.Cells
If Right(rFoundHd.Value, 2) = "id" Then
ActiveSheet.Range(rFoundHd,
rFoundHd.End(xlDown)).Select
With Selection
.HorizontalAlignment = xlRight
.NumberFormat = "@"
End With
End If
Next rFoundHd

'Replace #NULL! with empty cell
Cells.Replace What:="#NULL!", Replacement:="",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

'find Worker Name and run ProperCase on that column
Set rFoundHd = rTtl.Find("Worker Name", _
LookIn:=xlValues)
If Not rFoundHd Is Nothing Then
ActiveSheet.Range(rFoundHd, rFoundHd.End(xlDown)).Select
ProperCase

End If

Rows("1:1").Select
With Selection
.HorizontalAlignment = xlCenter

End With

Application.ScreenUpdating = True

End Sub


Sub ChngHeader()

Dim rOldHds As Range
Dim cell As Range
Dim strOldHd As String
Dim strNewHd As String
Dim lEndRow As Long
Dim wbkNewHdr As Workbook

Set wbkNewHdr = Workbooks("Test Overall Statewide and County
Percentages.xls")
Set wbkData = Workbooks("Reunification Exit.xls")
ActiveSheet.Range("A1").Select
Set rTtl = Range(Selection, Selection.End(xlToRight))


lEndRow = wbkNewHdr.Sheets("Macro Records").Cells(Rows.Count,
2).End(xlUp).Row
With wbkNewHdr.Sheets("Macro Records")
Set rOldHds = Range(.Cells(40, 2), .Cells(lEndRow, 2))
End With

For Each cell In rOldHds
strOldHd = cell.Value
strNewHd = cell.Offset(0, 1).Value


ERROR--Set rFoundHd =
wbkData.Worksheets(1).Range(rTtl).Find(strOldHd, LookIn:=xlValues)

If Not rFoundHd Is Nothing Then
rFoundHd.Value = strNewHd
End If
Next cell

End Sub

Thanks again!

 
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
Excel 2007 - error saving file & error loading dll TinaF Excel Discussion (Misc queries) 0 July 1st 09 01:49 PM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM


All times are GMT +1. The time now is 06:46 AM.

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"