ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error: Nonblank cells cannot be shifted off the spreadsheet. (https://www.excelbanter.com/excel-programming/319664-error-nonblank-cells-cannot-shifted-off-spreadsheet.html)

Raghu

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


All times are GMT +1. The time now is 08:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com