Macros and merged cells

D

DFrank

im trying to run a macro that combines a bunch of other macros. i have one
macro that sorts a list to prepare it for a vlookup. when running the macro
seperately, it works fine. when trying to run the macro through another
macro, i get an error.

here is my first macro:

Range("A1:B500").Select
Range("B500").Activate
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveWindow.LargeScroll Down:=-1
Range("B475").Select
ActiveWindow.LargeScroll Down:=-1
Range("B450").Select
ActiveWindow.LargeScroll Down:=-1
Range("B425").Select
ActiveWindow.LargeScroll Down:=-1
Range("B400").Select
ActiveWindow.LargeScroll Down:=-1
Range("B375").Select
ActiveWindow.LargeScroll Down:=-1
Range("B350").Select
ActiveWindow.LargeScroll Down:=-1
Range("B325").Select
ActiveWindow.LargeScroll Down:=-1
Range("B300").Select
ActiveWindow.LargeScroll Down:=-1
Range("B275").Select
ActiveWindow.LargeScroll Down:=-1
Range("B250").Select
ActiveWindow.LargeScroll Down:=-1
Range("B225").Select
ActiveWindow.LargeScroll Down:=-1
Range("B200").Select
ActiveWindow.LargeScroll Down:=-1
Range("B175").Select
ActiveWindow.LargeScroll Down:=-1
Range("B150").Select
ActiveWindow.LargeScroll Down:=-1
Range("B125").Select
ActiveWindow.LargeScroll Down:=-1
Range("B100").Select
ActiveWindow.LargeScroll Down:=-1
Range("B75").Select
ActiveWindow.LargeScroll Down:=-1
Range("B50").Select
ActiveWindow.LargeScroll Down:=-1
Range("B25").Select
ActiveWindow.LargeScroll Down:=-1
Range("B25").Select
ActiveWindow.SmallScroll Down:=6
Range("A1:B26").Select
Range("B26").Activate
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=-30
Range("D17").Select
End Sub






here is the macro with all the combined macos:
Public Sub Compile()
Application.Run "'BKW Proposal2.xls'!clear_errorsMid"
Application.Run "'BKW Proposal2.xls'!clear_rows"
Application.Run "'BKW Proposal2.xls'!Sort"
Application.Run "'BKW Proposal2.xls'!copyy"
Application.Run "'BKW Proposal2.xls'!sortforvlookup"
ActiveWindow.SmallScroll Down:=15
Range("D21").Select
End Sub





like i said, when i run 'sortforvlookup' by itself it works, but when i try
to run it through the macro 'Compile,' i get the following error:


Run-Time error '1004':
This operation requires the merged cells to be identitcally sized.

when i go to debug, the following of 'sortforvlookup' is highlighted:

Range("A1:B500").Select
Range("B500").Activate
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal


with the arrow being on "DataOption1:=xlSortNormal"


This is weird because none of the cells are merged. any ideas what this is
about? thanks.
 
D

DFrank

nevermind, i just forgot to add Sheets("Sheet1").Select to the begining of
the amcro. im a fool.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top