View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
engineer[_2_] engineer[_2_] is offline
external usenet poster
 
Posts: 1
Default Excel VBA - Storing text in a variable, and "'Cells' of object _Global failed"

Have searched through all the posts, but had no luck finding an existin
answer.

Here's the part of the code that is the problem. The worksheet
always contains one word of text in column 1. The variable ID i
intended to store that text, to be used later to create a chart title.


Dim Flag As Boolean
Dim i As Integer
Dim Start As Integer
Dim ID As Range
Dim sheetname As String

sheetname = ActiveSheet.Name
ActiveSheet.Select
Range("A1").Select
For i = 6 To 100
If Flag = False Then
Start = i
Set ID = Range(Cells(Start, 1), Cells(Start, 1))
Flag = True
End If

Have also tried changing the following two lines in the code:

Dim ID As String
ID = Range(Cells(Start, 1), Cells(Start, 1))

The first time through, the variable ID works fine and the chart i
created. However, when the text in column 1 changes, the error messag
"'Cells' of object _Global failed" shows on the assignment statemen
for the ID variable.

Any help for a newbie to this forum would certainly be appreciated

--
Message posted from http://www.ExcelForum.com