Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default set cell contents to Zero but keep cell formula in VBA

I have a spreadsheet with 3000 and some rows. I am using the code below to
initialise cells to 0 and this works fine. The problem is that some of the
cells contain formulae and when I initialise to 0, the formulae are not kept.
I just want to initialize cell contents and not loose the cell formulae.
Any suggestions in VBA please?

Sub initializeCells()
v = 0#
n = Cells(Rows.count, "C").End(xlUp).Row
Range("C13:F" & n).Value = v
End Sub
--
Ruth_C
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default set cell contents to Zero but keep cell formula in VBA

Sub initializeCells()

LastRow = Cells(Rows.Count, "C").End(xlUp).Row
Set DataRange = Range("C13:F" & LastRow)
DataRange.SpecialCells(xlCellTypeConstants) = 0

End Sub

"Ruth_C" wrote:

I have a spreadsheet with 3000 and some rows. I am using the code below to
initialise cells to 0 and this works fine. The problem is that some of the
cells contain formulae and when I initialise to 0, the formulae are not kept.
I just want to initialize cell contents and not loose the cell formulae.
Any suggestions in VBA please?

Sub initializeCells()
v = 0#
n = Cells(Rows.count, "C").End(xlUp).Row
Range("C13:F" & n).Value = v
End Sub
--
Ruth_C

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default set cell contents to Zero but keep cell formula in VBA

Thank you Joel works like a charm
--
Ruth_C


"Joel" wrote:

Sub initializeCells()

LastRow = Cells(Rows.Count, "C").End(xlUp).Row
Set DataRange = Range("C13:F" & LastRow)
DataRange.SpecialCells(xlCellTypeConstants) = 0

End Sub

"Ruth_C" wrote:

I have a spreadsheet with 3000 and some rows. I am using the code below to
initialise cells to 0 and this works fine. The problem is that some of the
cells contain formulae and when I initialise to 0, the formulae are not kept.
I just want to initialize cell contents and not loose the cell formulae.
Any suggestions in VBA please?

Sub initializeCells()
v = 0#
n = Cells(Rows.count, "C").End(xlUp).Row
Range("C13:F" & n).Value = v
End Sub
--
Ruth_C

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
using cell contents in a formula theadore Excel Worksheet Functions 2 September 13th 07 12:10 PM
Need to have cell C8 contain contents of Cell G(formula) Skip Excel Discussion (Misc queries) 1 April 25th 06 02:38 AM
Using cell contents within a formula Patrick Simonds Excel Worksheet Functions 2 December 17th 05 09:52 PM
formula for different cell contents sweetsue516 Excel Programming 1 September 1st 05 03:23 AM
Cell contents vs. Formula contents Sarah Excel Discussion (Misc queries) 3 December 15th 04 06:02 PM


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