Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
SLP SLP is offline
external usenet poster
 
Posts: 58
Default sub won't fill down via code

Hi, I have a sub that inserts the fill color of A1 into B2. The code is
supposed to copy the formula down but it doesn't although the fill down code
works all other times. I can manually pull the fill down but don't want my
end users to have to do that. Here is the code. Anyone see anything I
don't? Thanks.

Function GetFillColor(rng As Range) As Long
GetFillColor = rng.Interior.ColorIndex
End Function
Sub GetFillNEW()


Application.ScreenUpdating = False
Application.StatusBar = "Now processing"
Application.DisplayAlerts = False


Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Range("B1").Select
ActiveCell.FormulaR1C1 = "=GetFillColor(RC[-1])"
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:B1705"), Type:=xlFillDefault


Application.ScreenUpdating = True
Application.StatusBar = "Ready"
Application.DisplayAlerts = True

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default sub won't fill down via code

Add this at the end of your code:
Cells.Replace What:="=", Replacement:="=", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"SLP" wrote:

Hi, I have a sub that inserts the fill color of A1 into B2. The code is
supposed to copy the formula down but it doesn't although the fill down code
works all other times. I can manually pull the fill down but don't want my
end users to have to do that. Here is the code. Anyone see anything I
don't? Thanks.

Function GetFillColor(rng As Range) As Long
GetFillColor = rng.Interior.ColorIndex
End Function
Sub GetFillNEW()


Application.ScreenUpdating = False
Application.StatusBar = "Now processing"
Application.DisplayAlerts = False


Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Range("B1").Select
ActiveCell.FormulaR1C1 = "=GetFillColor(RC[-1])"
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:B1705"), Type:=xlFillDefault


Application.ScreenUpdating = True
Application.StatusBar = "Ready"
Application.DisplayAlerts = True

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default sub won't fill down via code

My bad, I checked the code and it tries to recalculate the formula each time
therefore just replace your code for this. I did test it and it
works.Function GetFillColor(rng As Range) As Long
GetFillColor = rng.Interior.ColorIndex
End Function
Sub GetFillNEW()


Application.ScreenUpdating = False
Application.StatusBar = "Now processing"
Application.DisplayAlerts = False


Columns("B:B").Select
Selection.Insert Shift:=xlToRight

Range("B1:B1705").FormulaR1C1 = "=GetFillColor(RC[-1])"
Application.ScreenUpdating = True
Application.StatusBar = "Ready"
Application.DisplayAlerts = True
End Sub


--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"SLP" wrote:

Hi, I have a sub that inserts the fill color of A1 into B2. The code is
supposed to copy the formula down but it doesn't although the fill down code
works all other times. I can manually pull the fill down but don't want my
end users to have to do that. Here is the code. Anyone see anything I
don't? Thanks.

Function GetFillColor(rng As Range) As Long
GetFillColor = rng.Interior.ColorIndex
End Function
Sub GetFillNEW()


Application.ScreenUpdating = False
Application.StatusBar = "Now processing"
Application.DisplayAlerts = False


Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Range("B1").Select
ActiveCell.FormulaR1C1 = "=GetFillColor(RC[-1])"
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:B1705"), Type:=xlFillDefault


Application.ScreenUpdating = True
Application.StatusBar = "Ready"
Application.DisplayAlerts = True

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
SLP SLP is offline
external usenet poster
 
Posts: 58
Default sub won't fill down via code

Thank you very much. I'll have happy end users now. Enjoy the weekend.

"Michael" wrote:

My bad, I checked the code and it tries to recalculate the formula each time
therefore just replace your code for this. I did test it and it
works.Function GetFillColor(rng As Range) As Long
GetFillColor = rng.Interior.ColorIndex
End Function
Sub GetFillNEW()


Application.ScreenUpdating = False
Application.StatusBar = "Now processing"
Application.DisplayAlerts = False


Columns("B:B").Select
Selection.Insert Shift:=xlToRight

Range("B1:B1705").FormulaR1C1 = "=GetFillColor(RC[-1])"
Application.ScreenUpdating = True
Application.StatusBar = "Ready"
Application.DisplayAlerts = True
End Sub


--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"SLP" wrote:

Hi, I have a sub that inserts the fill color of A1 into B2. The code is
supposed to copy the formula down but it doesn't although the fill down code
works all other times. I can manually pull the fill down but don't want my
end users to have to do that. Here is the code. Anyone see anything I
don't? Thanks.

Function GetFillColor(rng As Range) As Long
GetFillColor = rng.Interior.ColorIndex
End Function
Sub GetFillNEW()


Application.ScreenUpdating = False
Application.StatusBar = "Now processing"
Application.DisplayAlerts = False


Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Range("B1").Select
ActiveCell.FormulaR1C1 = "=GetFillColor(RC[-1])"
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:B1705"), Type:=xlFillDefault


Application.ScreenUpdating = True
Application.StatusBar = "Ready"
Application.DisplayAlerts = True

End Sub

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
VBA code to fill down Secret Squirrel Excel Discussion (Misc queries) 6 May 23rd 08 05:48 PM
auto fill code balu Excel Discussion (Misc queries) 3 November 19th 07 07:08 PM
Fill down - adjust code J.W. Aldridge Excel Programming 2 August 4th 07 02:46 PM
List Fill Code Cody Excel Programming 5 August 2nd 05 05:19 PM
find & delete + fill to end code? direwolf Excel Programming 16 January 5th 04 03:25 AM


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