ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert colum with 0's (https://www.excelbanter.com/excel-programming/272124-insert-colum-0s.html)

Henrik Bonde

Insert colum with 0's
 
Hi
During execution of a macro converting a *.xls to *.txt, i need to
insert a colum containing only zeros.
But it has to be the same length (number of rows), as the colum next
to it.

How to?

Best Regards
Henrik Bonde

JMay

Insert colum with 0's
 
Bob:
I get Compile error - Sub or Function not defined, when trying this; Can
you review and comment on the possibilities??
Tks,
JMay

"Bob Phillips" wrote in message
...
Henrik,

This inserts the column after D

Sub InsertColumn()
Dim cRows As Long

cRows = Cells(Rows.Count, "D").End(xlUp).row
Columns("E:E").EntireColumn.Insert
Range("E1:E" & cRows).Value = "0"
End Sub


--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Henrik Bonde" wrote in message
...
Hi
During execution of a macro converting a *.xls to *.txt, i need to
insert a colum containing only zeros.
But it has to be the same length (number of rows), as the colum next
to it.

How to?

Best Regards
Henrik Bonde






Henrik Bonde

Insert colum with 0's
 
On Sat, 19 Jul 2003 23:48:13 +0100, "Bob Phillips"
wrote:

This inserts the column after D

Sub InsertColumn()
Dim cRows As Long

cRows = Cells(Rows.Count, "D").End(xlUp).row
Columns("E:E").EntireColumn.Insert
Range("E1:E" & cRows).Value = "0"
End Sub


That's the ticket
Thanks a lot :-)

Henrik


Mvh
Henrik Bonde

Ved svar via email, tryk ikke svar/reply,
adressen der virker ikke.
Men svar til HbondeSNABELAit.dk

Bob Phillips[_5_]

Insert colum with 0's
 
Struggling on that one. It's so simple it's difficult to see where that
error could arise. I don't get it, and as Tom says, it worked for him.

Any other details?

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"JMay" wrote in message news:ScoSa.2767$If5.298@lakeread06...
Bob:
I get Compile error - Sub or Function not defined, when trying this; Can
you review and comment on the possibilities??
Tks,
JMay

"Bob Phillips" wrote in message
...
Henrik,

This inserts the column after D

Sub InsertColumn()
Dim cRows As Long

cRows = Cells(Rows.Count, "D").End(xlUp).row
Columns("E:E").EntireColumn.Insert
Range("E1:E" & cRows).Value = "0"
End Sub


--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Henrik Bonde" wrote in message
...
Hi
During execution of a macro converting a *.xls to *.txt, i need to
insert a colum containing only zeros.
But it has to be the same length (number of rows), as the colum next
to it.

How to?

Best Regards
Henrik Bonde








JMay

Insert colum with 0's
 
Heck if I know, maybe 3 or 4 spaces (" ") that got into the mix (I might
have screwed around with the code after pasting, but before running..
anyway I
sure do appreciate your help, Bob.
JMay
Virginia, USA

"Bob Phillips" wrote in message
...
Didn't we do well<g.

What's a blue block by the way?

Bob

"JMay" wrote in message

news:w2vSa.2777$If5.412@lakeread06...
OK, I played around with it, deleted out the space occupied by the Blue
Block, and PRESTO, I'm OK; << Another "learning experience"...Thanks

guys
for verifying there wasn't a problem with the code..


"JMay" wrote in message
news:mLuSa.2776$If5.2397@lakeread06...
Tom/Bob:
My Code: After running and getting the Compile Error Sub or Function

not
defined -- Where I've placed the **** below there is actually a full

3
or
4
space Blue Block, which might give a clue as to what's going on;

that's
all
I can offer.
Thanks for taking a look...

Sub InsertColumn()
Dim cRows As Long
cRows = Cells(Rows.Count, "D").End(xlUp).Row
**** Columns("E:E").EntireColumn.Insert
Range("E1:E" & cRows).Value = "0"
End Sub

"Tom Ogilvy" wrote in message
...
Pasted into a general module and it ran fine for me.

Regards,
Tom Ogilvy


JMay wrote in message

news:ScoSa.2767$If5.298@lakeread06...
Bob:
I get Compile error - Sub or Function not defined, when trying

this;
Can
you review and comment on the possibilities??
Tks,
JMay

"Bob Phillips" wrote in message
...
Henrik,

This inserts the column after D

Sub InsertColumn()
Dim cRows As Long

cRows = Cells(Rows.Count, "D").End(xlUp).row
Columns("E:E").EntireColumn.Insert
Range("E1:E" & cRows).Value = "0"
End Sub


--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Henrik Bonde" wrote in message
...
Hi
During execution of a macro converting a *.xls to *.txt, i

need
to
insert a colum containing only zeros.
But it has to be the same length (number of rows), as the

colum
next
to it.

How to?

Best Regards
Henrik Bonde
















All times are GMT +1. The time now is 05:58 PM.

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