ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to set a range equal to cells greater than 0 (Column "A" only) (https://www.excelbanter.com/excel-programming/398593-how-set-range-equal-cells-greater-than-0-column-only.html)

Alex St-Pierre

How to set a range equal to cells greater than 0 (Column "A" only)
 
Thank you!
Aex
--
Alex St-Pierre

Roger Whitehead[_2_]

How to set a range equal to cells greater than 0 (Column "A" only)
 
If row 65536 is free (Excel <=2003) -

Columns(1).Insert

Set myrange = Columns("B").SpecialCells(xlCellTypeConstants, xlNumbers)

myrange.Offset(0, -1).FormulaR1C1 = "=IF(RC20,1,"""")"
With myrange.Offset(0, -1)
.Value = .Value
End With

'Watch for the word wrap on next line-
Set myrange = myrange.Offset(0, -1).SpecialCells(xlCellTypeConstants,
xlNumbers).Offset(0, 1)
Columns(1).Delete

Debug.Print myrange.Address


--
---
HTH
Roger
Shaftesbury (UK)
(Excel 2003, Win XP/SP2)



"Alex St-Pierre" wrote in message
...
Thank you!
Aex
--
Alex St-Pierre




Roger Whitehead[_2_]

How to set a range equal to cells greater than 0 (Column "A" only)
 
Sorry, that should have been 'Column IV', not 'Row 65536'....


"Roger Whitehead" wrote in message
...
If row 65536 is free (Excel <=2003) -

Columns(1).Insert

Set myrange = Columns("B").SpecialCells(xlCellTypeConstants, xlNumbers)

myrange.Offset(0, -1).FormulaR1C1 = "=IF(RC20,1,"""")"
With myrange.Offset(0, -1)
.Value = .Value
End With

'Watch for the word wrap on next line-
Set myrange = myrange.Offset(0, -1).SpecialCells(xlCellTypeConstants,
xlNumbers).Offset(0, 1)
Columns(1).Delete

Debug.Print myrange.Address


--
---
HTH
Roger
Shaftesbury (UK)
(Excel 2003, Win XP/SP2)



"Alex St-Pierre" wrote in message
...
Thank you!
Aex
--
Alex St-Pierre







All times are GMT +1. The time now is 12:54 PM.

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