ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Type mismatch error (https://www.excelbanter.com/excel-programming/355563-type-mismatch-error.html)

Metrazal[_38_]

Type mismatch error
 

What am I missing? Getting the above error with this code. I want t
subtract the column "e" from "d" put the results in column "f" an
delete column "e" & "d".

Thanks,

Met




Code
-------------------

Sub Calculate_Delete()
Worksheets("Invoice").Select
For a = 1 To 1000
Cells(a, "f").Value = Cells(a, "d").Value - Cells(a, "e").Value
Next a
Sheets("Invoice").Columns("d:d").EntireColumn.Dele te
Sheets("Invoice").Columns("e:e").EntireColumn.Dele te
End Sub

-------------------

--
Metraza
-----------------------------------------------------------------------
Metrazal's Profile: http://www.excelforum.com/member.php...fo&userid=3164
View this thread: http://www.excelforum.com/showthread.php?threadid=52057


Dave Peterson

Type mismatch error
 
I'd guess that there was some non-numeric stuff in columns D or E.

Metrazal wrote:

What am I missing? Getting the above error with this code. I want to
subtract the column "e" from "d" put the results in column "f" and
delete column "e" & "d".

Thanks,

Met

Code:
--------------------

Sub Calculate_Delete()
Worksheets("Invoice").Select
For a = 1 To 1000
Cells(a, "f").Value = Cells(a, "d").Value - Cells(a, "e").Value
Next a
Sheets("Invoice").Columns("d:d").EntireColumn.Dele te
Sheets("Invoice").Columns("e:e").EntireColumn.Dele te
End Sub

--------------------

--
Metrazal
------------------------------------------------------------------------
Metrazal's Profile: http://www.excelforum.com/member.php...o&userid=31648
View this thread: http://www.excelforum.com/showthread...hreadid=520573


--

Dave Peterson

Edward Ulle

Type mismatch error
 
One other word of caution. Once you delete column D, column E becomes
D. Delete E first then D.



*** Sent via Developersdex http://www.developersdex.com ***

Metrazal[_39_]

Type mismatch error
 

Thats it, stupid me had some text way down my spreadsheet.

Thanks,

Met


--
Metrazal
------------------------------------------------------------------------
Metrazal's Profile: http://www.excelforum.com/member.php...o&userid=31648
View this thread: http://www.excelforum.com/showthread...hreadid=520573


Dave Peterson

Type mismatch error
 
Or just get them both at once:

Sheets("Invoice").Columns("d:E").EntireColumn.Dele te



Edward Ulle wrote:

One other word of caution. Once you delete column D, column E becomes
D. Delete E first then D.

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson


All times are GMT +1. The time now is 10:03 PM.

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