Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel errors driving me nuts

Status
Not open for further replies.

baronvont

Technical User
May 15, 2001
77
AU
Hi, can anyone help out here. I am developing some code to automate a spreadsheet and 2 bits just won't work..

1. a simple sort routine.. (1st I need to find the last used cell)

NewName = Application.InputBox("Enter the Student's Whole name")

With Worksheets("students").Range("a:a")

Set c = .Find("") , LookIn:=xlValues, lookat:=xlWhole)
Address = Right(c.Address, Len(c.Address) - 3)
.Range("B" & Address).Value = Address
.Range("A" & Address).Value = NewName
.Range("A1:B" & Address).Sort key1:=Worksheets("students").Range("A1")

End With

This returns "Runtime Err '1004' - Unable to get the find property of the range class" at the Set c = .... line. Sometimes, if I step the code it goes thru, but then stops at the sort line with same err.

and 2...

Worksheets("Main").Range("a1:az20").Font.ColorIndex = 1

gives "Unable to set the colorindex property of the font class"

BUT... in the same sheet, this bit does work...

Sub Worksheet_change(ByVal Target As Range)

......

Target.Font.ColorIndex = 3


I've tried re-creating the sheet in case there is some underlying error but it's the same.. please can someone help?

Thanks
Georg
 
Can't offer much help on the first bit.

As to the second problem, this code works for me to set font color.

ActiveSheet.Rows(IntR).Columns(IntC).Font.ColorIndex

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top