ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting a Column from a Workbook (https://www.excelbanter.com/excel-programming/302055-deleting-column-workbook.html)

Terry

Deleting a Column from a Workbook
 
We want to delete a column in a workbook without
activating the workbook. The code below is supposed to
check whether cell A1 is null. If it is, we want to delete
column A from the workbook without activating that
workbook, but can't get the syntax right. (The Test
workbook has only one workshet.)

If Workbooks("Test.xls").Range("A1") = "" Then
Workbooks("Test.xls").Columns("A").Delete
End If

Help, please.

Thanks.

Juan Pablo González

Deleting a Column from a Workbook
 
Change

Workbooks("Test.xls").Range("A1")

with

Workbooks("Test.xls").Sheets("YourSheet").Range("A 1")

--
Regards

Juan Pablo González

"Terry" wrote in message
...
We want to delete a column in a workbook without
activating the workbook. The code below is supposed to
check whether cell A1 is null. If it is, we want to delete
column A from the workbook without activating that
workbook, but can't get the syntax right. (The Test
workbook has only one workshet.)

If Workbooks("Test.xls").Range("A1") = "" Then
Workbooks("Test.xls").Columns("A").Delete
End If

Help, please.

Thanks.




Terry

Deleting a Column from a Workbook
 
The second line of code does not work - the formatting is
incorrect. I get an "Error 13 - Type Mismatch." Any
suggestions on how to get the cloumn deleted?

-----Original Message-----
Change

Workbooks("Test.xls").Range("A1")

with

Workbooks("Test.xls").Sheets("YourSheet").Range(" A1")

--
Regards

Juan Pablo González

"Terry" wrote in

message
...
We want to delete a column in a workbook without
activating the workbook. The code below is supposed to
check whether cell A1 is null. If it is, we want to

delete
column A from the workbook without activating that
workbook, but can't get the syntax right. (The Test
workbook has only one workshet.)

If Workbooks("Test.xls").Range("A1") = "" Then
Workbooks("Test.xls").Columns("A").Delete
End If

Help, please.

Thanks.



.


Juan Pablo González

Deleting a Column from a Workbook
 
Workbooks("Test.xls").Sheets("YourSheet").Range("A 1").EntireColumn.Delete

--
Regards

Juan Pablo González

"Terry" wrote in message
...
The second line of code does not work - the formatting is
incorrect. I get an "Error 13 - Type Mismatch." Any
suggestions on how to get the cloumn deleted?

-----Original Message-----
Change

Workbooks("Test.xls").Range("A1")

with

Workbooks("Test.xls").Sheets("YourSheet").Range(" A1")

--
Regards

Juan Pablo González

"Terry" wrote in

message
...
We want to delete a column in a workbook without
activating the workbook. The code below is supposed to
check whether cell A1 is null. If it is, we want to

delete
column A from the workbook without activating that
workbook, but can't get the syntax right. (The Test
workbook has only one workshet.)

If Workbooks("Test.xls").Range("A1") = "" Then
Workbooks("Test.xls").Columns("A").Delete
End If

Help, please.

Thanks.



.




Terry

Deleting a Column from a Workbook
 
Muy Bien!
Gracias.

-----Original Message-----
Workbooks("Test.xls").Sheets("YourSheet").Range

("A1").EntireColumn.Delete

--
Regards

Juan Pablo González

"Terry" wrote in

message
...
The second line of code does not work - the formatting is
incorrect. I get an "Error 13 - Type Mismatch." Any
suggestions on how to get the cloumn deleted?

-----Original Message-----
Change

Workbooks("Test.xls").Range("A1")

with

Workbooks("Test.xls").Sheets("YourSheet").Range( "A1")

--
Regards

Juan Pablo González

"Terry" wrote in

message
.. .
We want to delete a column in a workbook without
activating the workbook. The code below is supposed to
check whether cell A1 is null. If it is, we want to

delete
column A from the workbook without activating that
workbook, but can't get the syntax right. (The Test
workbook has only one workshet.)

If Workbooks("Test.xls").Range("A1") = "" Then
Workbooks("Test.xls").Columns("A").Delete
End If

Help, please.

Thanks.



.



.


Don Guillett[_4_]

Deleting a Column from a Workbook
 
Gotta open
Sub delcols()
Workbooks.Open ("del.xls")
With ActiveWindow
If Range("a1") = "" Then Columns(1).Delete
End With
End Sub

--
Don Guillett
SalesAid Software

"Terry" wrote in message
...
We want to delete a column in a workbook without
activating the workbook. The code below is supposed to
check whether cell A1 is null. If it is, we want to delete
column A from the workbook without activating that
workbook, but can't get the syntax right. (The Test
workbook has only one workshet.)

If Workbooks("Test.xls").Range("A1") = "" Then
Workbooks("Test.xls").Columns("A").Delete
End If

Help, please.

Thanks.




Don Guillett[_4_]

Deleting a Column from a Workbook
 
or if open but not active. Don't forget the .'s before range and columns

Sub delcols1() 'if open
With Workbooks("del.xls").Sheets(1)
If .Range("a1") = "" Then .Columns("A").Delete
End With
End Sub

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
Gotta open
Sub delcols()
Workbooks.Open ("del.xls")
With ActiveWindow
If Range("a1") = "" Then Columns(1).Delete
End With
End Sub

--
Don Guillett
SalesAid Software

"Terry" wrote in message
...
We want to delete a column in a workbook without
activating the workbook. The code below is supposed to
check whether cell A1 is null. If it is, we want to delete
column A from the workbook without activating that
workbook, but can't get the syntax right. (The Test
workbook has only one workshet.)

If Workbooks("Test.xls").Range("A1") = "" Then
Workbooks("Test.xls").Columns("A").Delete
End If

Help, please.

Thanks.







All times are GMT +1. The time now is 02:40 AM.

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