Solved

Delete Excel Column From Access

Posted on 2013-10-28
11
433 Views
Last Modified: 2013-11-12
I need to delete an Excel column (P) from MS Access using VBA. Any thoughts. After deletion I need to save the WB and close Excel.
0
Comment
Question by:shieldsco
  • 3
  • 2
  • 2
11 Comments
 
LVL 35

Expert Comment

by:[ fanpages ]
Comment Utility
Hi,

Sorry, but your requirement is not completely clear (to me).

How is column [P] within the MS-Excel workbook associated/linked with a column within an MS-Access database table?

Have you already opened a connection to the database &, hence, do you just need help with the code to remove a column from the MS-Access database schema (table definition)?

Thank you for your clarification & provision of all the relevant details to proceed.

BFN,

fp.
0
 

Author Comment

by:shieldsco
Comment Utility
I'm using  Access and I want to delete an Excel column using Access VBA. If this helps, I'm using the following code to to convert two Excel columns to text using VBA from an Access button.

'Convert Columns A and B to Text
Private Sub Udate_Click()
 Set objApp = CreateObject("Excel.Application")
        objApp.Visible = False
        Set wb = objApp.Workbooks.Open("\\cdc\project\OD_FMO_DEBT_MGT\Cash Recon Database\General Fund FOIA.xlsx", True, False)
   
    wb.Sheets(1).Range("A:B").NumberFormat = "@"
    wb.Save
    wb.Close
  objApp.Quit
    Set objApp = Nothing
0
 

Author Comment

by:shieldsco
Comment Utility
I figured it out -- thanks. Here is the code

Private Sub Command0_Click()
 Set objApp = CreateObject("Excel.Application")
        objApp.Visible = True
        Set wb = objApp.Workbooks.Open("\\cdc\project\OD_FMO_DEBT_MGT\Cash Recon Database\General Fund FOIA.xlsx", True, False)
   
    Columns("P:P").Delete

    wb.Save
    wb.Close
  objApp.Quit
    Set objApp = Nothing
   
End Sub
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 35

Expert Comment

by:[ fanpages ]
Comment Utility
If you worked out a solution, then there should be no reason to accept my comment at all.

I have used the "Request Attention" link above to ask for the question to be re-opened, so your own comment can be accepted (& so you do not use any of your points on this question).
0
 
LVL 5

Expert Comment

by:Netminder
Comment Utility
I've requested that this question be closed as follows:

Accepted answer: 0 points for shieldsco's comment #a39605507

for the following reason:

Starting closing process on behalf of Asker.

Netminder
Senior Admin
0
 

Author Comment

by:shieldsco
Comment Utility
I figured it out -- thanks. Here is the code

Private Sub Command0_Click()
 Set objApp = CreateObject("Excel.Application")
        objApp.Visible = True
        Set wb = objApp.Workbooks.Open("\\cdc\project\OD_FMO_DEBT_MGT\Cash Recon Database\General Fund FOIA.xlsx", True, False)
   
    Columns("P:P").Delete

    wb.Save
    wb.Close
  objApp.Quit
    Set objApp = Nothing
   
End Sub
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
Comment Utility
I have requested this question be closed and the solution be archived.

Netminder
Senior Admin
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now