Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Excel programming using VBA

So the cells that should be moved look like: Spec. ####
(and contain nothing else????)

If that's true, then I think this'll work:

Option Explicit
Sub testme01()

Dim wks As Worksheet
Dim LookForStr As String
Dim FoundCell As Range
Dim lookThroughAddress As String

lookThroughAddress = "A:AE"
LookForStr = "spec. *"

For Each wks In ActiveWorkbook.Worksheets(Array("monday", "tuesday", _
"wednesday", "thursday", "Friday"))

wks.Range("G:G").Replace what:="spec.", _
Replacement:="xxxxspec.", lookat:=xlPart, MatchCase:=False

With wks.Range(lookThroughAddress)
Set FoundCell = .Cells.Find(what:=LookForStr, _
after:=.Cells(.Cells.Count), _
lookat:=xlWhole, SearchDirection:=xlNext)
If FoundCell Is Nothing Then
MsgBox LookForStr & " wasn't found in " & wks.Name
Else
Do
If FoundCell.Column = wks.Range("G:G").Column Then
'do nothing
Else
wks.Cells(FoundCell.Row, "G").Value _
= "xxxx" & FoundCell.Value
FoundCell.ClearContents
End If
Set FoundCell = .FindNext(FoundCell)
If FoundCell Is Nothing Then
Exit Do
End If
Loop
End If
End With

wks.Range("G:G").Replace what:="xxxxspec.", _
Replacement:="Spec.", lookat:=xlPart
Next wks
End Sub

It changes any Spec. in column G to xxxxSpec. That way, the macro can look for
"SPEC. *". If it finds it, it moves the value to column G (prepending xxxx
there, too).

(The xxxx stuff means that the find won't find it.)

At the end it changes xxxxSpec. back to Spec.



Lillian wrote:

I have one excel spredsheet with 5 different
worksheet "Monday", "Tuesday","Wednesday", "Thursday", "Fr
iday", each worksheet has about 2,500 records, I need to
find out on each records from ColumnA to Columns EA that
contain "spec. xxxx" then need to moved to columns G, and
leave the space there, example find "spec. xxxx" in
columnI then will be moved to columnG, then deleted
columnsI, leave space there.

Except one condition if find "spec. xxxx" within any long
paragraph will be ignored, example some of record like
this one, record #562 of Monday worksheet,on column H
has "Motion Awarding Bid, Spec. 2472 (Reclaimed Water
Pipeline) to Kershaw Construction Company, Inc." has
Sepc. 2472, just ignired, do not need to moved "Spec.
2472" to column G, on same record #562 on column N
has "spec. 2479", so only need to moved this column N to
columnG, and leave the space in column N.

Need help on this VBA, thank you so much

LIllian



--

Dave Peterson

Reply
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
Programming in Excel VBA or ??? stevec Excel Discussion (Misc queries) 4 December 11th 07 06:56 PM
Or Excel Programming Help Me please some body... Excel Worksheet Functions 1 August 2nd 07 11:32 PM
Excel Programming help Geoff D'Arcy Excel Worksheet Functions 2 November 1st 04 06:31 PM
Excel Programming in VB sapta Excel Programming 0 September 10th 03 05:52 AM
Excel Programming in VB Peter Atherton Excel Programming 2 September 9th 03 12:40 PM


All times are GMT +1. The time now is 03:34 AM.

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

About Us

"It's about Microsoft Excel"