HeadshotSam
New Member
- Joined
- May 13, 2014
- Messages
- 2
Hi,
I have been attempting to use SpecialCells in VBA to extract all the numbers in a column (of formulas) and 'paste' in another sheet.
The problem I'm having is the SpecialCells argument is only reading in the first instance where there is a number.
Code:
In this code I have count_cells as a count of the numbers in the range and examine_cells as a column of cells with a mixture of unique numbers and repeated text.
Example Range to carry out the code on could be
1
Apple
2
3
Apple
4
Apple
Apple
5
6
7
etc.
(I am running into this problem in Excel 2007 and Excel 2010 both running Windows 7)
Thanks,
HSS
I have been attempting to use SpecialCells in VBA to extract all the numbers in a column (of formulas) and 'paste' in another sheet.
The problem I'm having is the SpecialCells argument is only reading in the first instance where there is a number.
Code:
Code:
Option Explicit
Sub SpecialCellsTest()
Dim countCells As Integer
Dim cellsToExamine As Range
Dim cellsToPaste As Range
Application.ScreenUpdating = False
countCells = Range("count_cells").Value
Set cellsToExamine = Range("examine_cells")
Set cellsToPaste = cellsToExamine.Specialcells(xlCellTypeFormulas, xlNumbers)
Sheets(3).Range("A3:A" & 2 + countCells) = cellsToPaste.value
Application.ScreenUpdating = True
End Sub
In this code I have count_cells as a count of the numbers in the range and examine_cells as a column of cells with a mixture of unique numbers and repeated text.
Example Range to carry out the code on could be
1
Apple
2
3
Apple
4
Apple
Apple
5
6
7
etc.
(I am running into this problem in Excel 2007 and Excel 2010 both running Windows 7)
Thanks,
HSS
Last edited: