View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Raghu Raghu is offline
external usenet poster
 
Posts: 14
Default Error: Nonblank cells cannot be shifted off the spreadsheet.

Hi,
I am trying to add a new row to the grid for which
I have a Add button on my page. When i click this add button an error
message pops up as
Error: Nonblank cells cannot be shifted off the spreadsheet..

If i comment the Autofilter part in my onload procedure, i won't get the
error message, but i need this filter for the first row.

Could help me on this?

Sub Window_onLoad()
With objOWC
.ViewableRange = objIntelOWC.ActiveSheet.UsedRange.Address
.Titlebar.caption = "Loading Data..."
.ActiveSheet.Name = "Company"
.DisplayOfficeLogo = False
.DisplayTitleBar = True
.DisplayToolbar = False
.DisplayRowHeadings = True
.DisplayColumnHeadings = False
.DisplayVerticalScrollBar = False
.DisplayHorizontalScrollBar = False
.ActiveSheet.Cells(1,1).value = "Company Code"
.ActiveSheet.Cells(1,2).value = "Company Description"
.ActiveSheet.Rows(1).AutoFilter 'Problem line
.AutoFit = True
.ViewableRange = objIntelOWC.ActiveSheet.UsedRange.Address
.Titlebar.caption = "Done!"
.ActiveSheet.Protection.Enabled = True
End With
End Sub

sub btnAdd_onClick()
dim RowAdd
objOWC.ActiveSheet.Protection.Enabled = False
objOWC.TitleBar.Caption = "Adding Row"
with objOWC
RowAdd = .ActiveSheet.UsedRange.Rows.Count+1
.Rows(RowAdd).insert
.ActiveSheet.UsedRange.Rows.AutoFit
end with
objOWC.TitleBar.Caption = "Done!"
objOWC.ActiveSheet.Protection.Enabled = True
end sub