Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Problems Adding Columns--but data close to IV and no hidden objects

Hello,
I have a problem similar to that in the thread "Problems deleting
columns" on Jul. 2. The recommendations, and resolution at
http://support.microsoft.com/default.aspx?kbid=211769 do not work in
my case. My sheet will probably contain up to cols. DD or EE, but
will never go to IV. There is no data in IV. However, I have
inserted conditional formatting and have filled rows/columns. I
continue to get the run-time error 1004 "To prevent the possible loss
of data, Microsoft Excel cannot shift nonblank cells off the
worksheet..." error. This is stumping me; any ideas?

Thanks,
Arnold

Sub mcrActivities()

Sheets("Fields").Select

Dim ActivityDate As Range
Set ActivityDate = ActiveSheet.Range("C11")
ActivityDate.Value = Date

Columns("C:C").Select
Selection.Copy
Sheets("Quarter").Select
lastcolumn = ActiveSheet.Cells.Find(what:="Activity",
searchorder:=xlByColumns, searchdirection:=xlPrevious).Column
ActiveSheet.Cells(lastcolumn + 1).Offset(12, 0).Select

' Modified code to place new columns in front of the last column
with the text "Activity" in it on row 12; in the AAs.

ActiveSheet.Cells(lastcolumn).Offset(0, 0).EntireColumn.Insert

' Code to place the focus after a column insert.

ActiveSheet.Cells(lastcolumn).Offset(8, 0).Select

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Problems Adding Columns--but data close to IV and no hidden object

You could have some hidden data in the columns or rows at or near the end of
the sheet. To check that, put the code below in the standard VB code module
and run it one sheet at the time.

Sub chkRng()
ActiveSheet.UsedRange.Select
End Sub

This will shade all cells on the sheet that fall within the outerboundries
of cells that contain data, whether visible or not. You can scroll right and
down to see what the limits are. If none of your columns or rows of the used
range are near the outer limits of the sheet, then check the code you are
running one step at a time to see what line of code throws the error and if
it infact attempts to shift too far left or right. Sometimes, using the
offset method of cell references can cause the problem. For example if the
active cell is in column C and you use:

ActiveCell.Offset(0, -5)

There are only two columns available to shift and that will throw the error
message because you are attempting to shift five.

"Arnold" wrote:

Hello,
I have a problem similar to that in the thread "Problems deleting
columns" on Jul. 2. The recommendations, and resolution at
http://support.microsoft.com/default.aspx?kbid=211769 do not work in
my case. My sheet will probably contain up to cols. DD or EE, but
will never go to IV. There is no data in IV. However, I have
inserted conditional formatting and have filled rows/columns. I
continue to get the run-time error 1004 "To prevent the possible loss
of data, Microsoft Excel cannot shift nonblank cells off the
worksheet..." error. This is stumping me; any ideas?

Thanks,
Arnold

Sub mcrActivities()

Sheets("Fields").Select

Dim ActivityDate As Range
Set ActivityDate = ActiveSheet.Range("C11")
ActivityDate.Value = Date

Columns("C:C").Select
Selection.Copy
Sheets("Quarter").Select
lastcolumn = ActiveSheet.Cells.Find(what:="Activity",
searchorder:=xlByColumns, searchdirection:=xlPrevious).Column
ActiveSheet.Cells(lastcolumn + 1).Offset(12, 0).Select

' Modified code to place new columns in front of the last column
with the text "Activity" in it on row 12; in the AAs.

ActiveSheet.Cells(lastcolumn).Offset(0, 0).EntireColumn.Insert

' Code to place the focus after a column insert.

ActiveSheet.Cells(lastcolumn).Offset(8, 0).Select

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Problems Adding Columns--but data close to IV and no hidden object

Thanks JLGWhiz,
Ok, this is what is now happening. I think it has to do something
with the fills and conditional formatting that I've set up across the
entire sheet. So, now, I've cleared all columns from FF to IV of all
formatting. The code above will insert "Activity" columns just fine
now, but when I delete one of the columns (using Ctrl -), column IV
returns to/contains the fills/conditional formatting that I previously
cleared. For example, if I add 3 Activity columns, then delete 2 of
them, cols. IV and IU will become formatting. Then, when I try to add
another Activity col in the AA range, the error 1004 "To prevent the
possible loss... msg appears. What causes this?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Problems Adding Columns--but data close to IV and no hidden ob

I am not technically astute enough to give you a good answer to that
question. I would be guessing because I am not educated in the digital
construction of the .xls spreadsheet. I know that when you add or delete
rows and columns in xl95 thru xl2003 that there are still 256 x 65536 cells
no matter how many time you add or delete. How those deleted cells are
handled internally in memory is a mystery to me. There might be a way to
code around the anomaly although I have never tried it, because I have never
had the problem. I am thinking maybe when you execute the code that causes
the error message, you could insert a line to clear columns IU and IV or some
similar type work around. Again, I'm guessing at this point.

"Arnold" wrote:

Thanks JLGWhiz,
Ok, this is what is now happening. I think it has to do something
with the fills and conditional formatting that I've set up across the
entire sheet. So, now, I've cleared all columns from FF to IV of all
formatting. The code above will insert "Activity" columns just fine
now, but when I delete one of the columns (using Ctrl -), column IV
returns to/contains the fills/conditional formatting that I previously
cleared. For example, if I add 3 Activity columns, then delete 2 of
them, cols. IV and IU will become formatting. Then, when I try to add
another Activity col in the AA range, the error 1004 "To prevent the
possible loss... msg appears. What causes this?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Problems Adding Columns--but data close to IV and no hidden ob

Thanks again.

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
Chart data from hidden rows (not columns) wildetudor Charts and Charting in Excel 1 January 13th 09 03:52 PM
Prevent other users seeing hidden columns/data Mouettes Excel Discussion (Misc queries) 3 December 13th 07 11:14 AM
Pasting data with hidden columns shark1966 Excel Worksheet Functions 4 November 4th 06 04:00 AM
Adding specific objects based on data... Kay Excel Discussion (Misc queries) 2 July 14th 05 09:28 AM
Close Hidden Data Sheet Jeff Excel Programming 7 January 8th 05 09:48 PM


All times are GMT +1. The time now is 04:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"