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: 1
Default Range R1C1 notation & the problem with my Macro


Ok here goes,

I am trying to write a Macro that will search a defined range for a
specified term. Once the term is located a defined value will be
written in column A (C1) on the same row the search term was located.

I keep getting "Runtime Error '1004': Method 'Range' of Object
'_Global' failed." I am definitely a VB novice although this isn't my
first macro, but I can't seem to figure out what I am doing wrong. I
worked on this for about three hours today and couldn't get it. I am
probably just doing some stupid little thing wrong, but it might be a
bigger problem than that. If anyone could help me with this I would
really appreciate it (and so would my boss.) ;)

Thanks in advance.

Here is the code for reference:


Sub TheAttributer()

' Define Variables
Dim searchString As String
Dim attName As String
Dim searchRange As String
Dim d As Long


' Gather Variable Data by Popup Prompts
searchString = Application.InputBox(prompt:="Enter the string you wish
to search for", Type:=2)
attName = Application.InputBox(prompt:="Enter a name for this
attribute", Type:=2)
searchRange = Application.InputBox(prompt:="Enter A Cell Range to
search with in, i.e. x1:y2", Type:=2)


' Set range to be searched
With Worksheets("Product_Categories_5-25-05").Range(searchRange)

' Look for searchString in set range
Set c = .Find(What:=searchString, LookIn:=xlValues)

' If you don't find it keep going
If Not c Is Nothing Then
firstAddress = c.Address

' Write the defined value in col 1 on the same row that
contains search term
Do

d = c.Row
Range(Cells(d, 1)).Activate
ActiveCell.Value = attName
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress


End If
End With

End Sub


--
skiptabor
------------------------------------------------------------------------
skiptabor's Profile: http://www.excelforum.com/member.php...o&userid=23732
View this thread: http://www.excelforum.com/showthread...hreadid=374056

 
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
How do I change sheet notation from R1C1 style to A1 style in XL 2 Sherlock1506 Setting up and Configuration of Excel 1 December 5th 06 03:22 PM
Dynamic Range in Macro with R1C1 Jonnyboy117 Excel Programming 3 July 9th 04 04:40 PM
Using Range with R1C1 notation in a macro J Excel Programming 1 January 23rd 04 04:46 AM
Absolute reference in R1C1 notation Tim C Excel Programming 2 August 14th 03 11:54 PM
R1C1 Notation brym Excel Programming 4 July 27th 03 09:47 PM


All times are GMT +1. The time now is 03:26 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"