Link to home
Start Free TrialLog in
Avatar of shieldsco
shieldscoFlag for United States of America

asked on

Delete Excel Column From Access

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.
Avatar of [ fanpages ]
[ fanpages ]

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.
Avatar of shieldsco

ASKER

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
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
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).
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
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
ASKER CERTIFIED SOLUTION
Avatar of Netminder
Netminder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial