Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ksp ksp is offline
external usenet poster
 
Posts: 1
Default Macro Help - Loop Problems


Hi All

I have an existing macro (that works) that searches a particular column
for any text, and when it does it inserts one row. I have been trying
to adapt this same code to create a border on the top edge of the cell
where it finds text in column B (I actually need it to add the to
columns A-J for that row but haven't gotten that far yet). I can't use
CF as there are other borders I do not want in impact on.

Below is the code that I have, and being a real beginner I need some
help

Thanks in advance

Karen

Sub Borders()

With Range("B14:B40")
On Error Resume Next
Set C = .Find(What:="*", LookIn:=xlValues)
If Not C Is Nothing Then
firstaddress = C.Offset(1, 0).Address
Do
With Selection.Borders(xlEdgeTop)
..LineStyle = xlContinuous
..Weight = xlHairline
..ColorIndex = xlAutomatic
End With
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address < firstaddress
End If

End With


End Sub


--
ksp
------------------------------------------------------------------------
ksp's Profile: http://www.excelforum.com/member.php...fo&userid=6267
View this thread: http://www.excelforum.com/showthread...hreadid=537123

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Macro Help - Loop Problems

Good Morning KSP, Your code was real close. You left off the leading dots
in the second with and end with. I made few minor changes, It should work
for you now..(see code below)

Enjoy, Rick, (Fbks,Ak)

Option Explicit

Sub Borders()
Dim C As Range
Dim firstaddress As String

With Range("B14:B40")
On Error Resume Next
Set C = .Find(What:="*", LookIn:=xlValues)
If Not C Is Nothing Then
firstaddress = C.Offset(1, 0).Address
Do
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
Set C = .FindNext(C)
Loop While C.Address < firstaddress
End If
End With

End Sub

"ksp" wrote in message
...

Hi All

I have an existing macro (that works) that searches a particular column
for any text, and when it does it inserts one row. I have been trying
to adapt this same code to create a border on the top edge of the cell
where it finds text in column B (I actually need it to add the to
columns A-J for that row but haven't gotten that far yet). I can't use
CF as there are other borders I do not want in impact on.

Below is the code that I have, and being a real beginner I need some
help

Thanks in advance

Karen

Sub Borders()

With Range("B14:B40")
On Error Resume Next
Set C = .Find(What:="*", LookIn:=xlValues)
If Not C Is Nothing Then
firstaddress = C.Offset(1, 0).Address
Do
With Selection.Borders(xlEdgeTop)
LineStyle = xlContinuous
Weight = xlHairline
ColorIndex = xlAutomatic
End With
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address < firstaddress
End If

End With


End Sub


--
ksp
------------------------------------------------------------------------
ksp's Profile:

http://www.excelforum.com/member.php...fo&userid=6267
View this thread: http://www.excelforum.com/showthread...hreadid=537123



  #3   Report Post  
Posted to microsoft.public.excel.programming
ksp ksp is offline
external usenet poster
 
Posts: 1
Default Macro Help - Loop Problems


Hi Rick

I tried that and it still isn't working. I couldn't see any extra dot's
- do I just need new glasses?

Any suggestions?

Thanks

Karen


--
ksp
------------------------------------------------------------------------
ksp's Profile: http://www.excelforum.com/member.php...fo&userid=6267
View this thread: http://www.excelforum.com/showthread...hreadid=537123

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
Excel Macro loop problems mibsaweiss Excel Discussion (Misc queries) 0 March 16th 06 04:45 PM
problems with loop Arjan Excel Programming 1 December 8th 05 09:10 AM
So close! Problems with Loop Linking to specific cells in pivot table Excel Programming 3 February 7th 05 05:28 PM
for next loop problems cliee Excel Programming 3 November 1st 04 12:05 PM
Loop code problems pauluk[_51_] Excel Programming 2 April 23rd 04 10:30 AM


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