How to delete empty coulums in Excel using Macro

Dear Users,
i have prepared a very big excel file. actually this file is record of old prices and i vlook the the part number from different files and extract the old prices. some time there is no record so all the columns is empty. let me explain little more.....i
have excel files by year 1992 To 2013. most of the times i have to vlookup the old prices, now for exampe one item we just sale in 94,97and 2007, but except these years all the columns of other years from 92 to 2013 are empty. one by one check them top to
end and delete is very hard. is there any macro which checks the value from top to end, if there is no value so it delete all the coulum...........hope i could explain my question.................
Best Regards
Tahir Mehmood

Hi,
Please try this code:
Sub DeleteBlankColumns()
Dim c As Integer
'declare c as variable for column number
c = ActiveSheet.Cells.SpecialCells(xlLastCell).Column
'save last column number in used range
Do Until c = 0
'Loop for each column number until it equals 0
If WorksheetFunction.CountA(Columns(c)) = 0 Then
'Check if entire column is blank
Columns(c).Delete
'if column is blank delete column
End If
'closes if statement
c = c - 1
'proceeds to the next lowest column number
Loop
End Sub
PS:
This is the forum to discuss questions and feedback for Microsoft Excel, if you have further question, please post the thread to the MSDN forum for Excel
http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
George Zhao
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs.

Similar Messages

  • How to refresh the reports in excel using macros ?

    Hi All,
    I am generating a report using MS Excel to connecting the Sql Server 2008 Database.
    In the Sql Server the reporting table is a transaction table.
    When open the Excel report and click the Refresh All button under the Data tab. Then the report  takes the more time to load the data.
    I need the less time to load the data in the Excel report.
    How can you performance to increase the report to load the data quickly.
    Thanks in Advance.
    Thanks,
    Sreekanth
    sreekanth kancharla

    Hello,
    First, this is a forum for SSRS = SQL Server Reporting Services, not for Excel or other topics of your question.
    Do you have a filter in the query to get the data?
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Identify empty rows in Excell  using POI

    Hi,
    Could U please tell me how to identify empty rows in Excell sheet using Apachi POI (poi-3.6-20091214.jar).
    Thanks.
    DNA

    Hi,
    I used the following algorithm to identify empty rows (contains value deleted cells). within the main program it is used to by pass the empty rows in an excel sheet.
    If some one has a better solution please do share it with us.
    Program to identify empty rows
    {color:#3366ff}BEGIN
    row -> Instance of the row iterator. Goes through each row.
    cell -> Instance of the cell iterator. Goes through each cell.
    isCellEmpty -> boolean value to assign status.
    rowsToOmit -> An ArrayList which stores the omitted rows.
    WHILE(Has another row){
    get Cell Iterator of row
    WHILE(Cell Iterator Has another cell){
    IF(cell value == "")
    then isCellEmpty is TRUE
    ELSE{
    then isCellEmpty is FALSE
    BREAK
    IF(isCellEmpty value is true)
    Add row to rowsToOmit
    END{color}
    Edited by: nalagiri on Sep 19, 2010 11:37 PM

  • How to delete empty pages in in-design document?

    Hi All,
           How to delete empty page which may contains text frame with no contents, or may be no text frame...
    Plz provide me the script...
    Thanks in advance,
    Vel....

    Indesign CS5.
    My script is,
    doc=app.activeDocument;
    pageObj=doc.pages.item(0);
    txtObj=pageObj.textFrames.item(0);
    var temp=doc.pages.length;
    for(var i=0;i<temp;i++)
        if(doc.pages[i].textFrames.item(0)!=null)
                if(doc.pages[i].textFrames[0].contents!=null) // here, i used "contents" instead of "lines". but also not working well...
                    alert(doc.pages[i].textFrames[0].contents);
                    alert("True");
                else
                    doc.pages[i].remove();
                    i=i-1;
                    temp--;
        else
          alert("False");
          doc.pages[i].remove();
          i=i-1;
          temp--;
    I've a sample document which contains a empty page without a text frame and another empty page with text frame with no contents on it... but my script remove only the empty page and not the empty page with txt frame...
    pLZ HELP JONGWARE...

  • How to Download displayed output to Excel Using Bsp Application

    Hi Experts,
    please give me some idea because I am New In BSP.
    How to Download displayed output to Excel Using Bsp Application.
    If any sample code please do send me.
    In my condition I am getting data in  2-3 table view formats on one page and i want download that in Excel.
    please help me.
    Regards & Thanks,
    Yogesh

    Hi,
    This is more a question for the BSP forum.
    Anyway, as such it's realy easy since you can use HTML in order to import to Excel. All you need to do is add
    runtime->server->response->set_header_field( name = 'Contnet-Type'
    value = 'application/vnd.ms-excel' ).
    runtime->server->response->delete_header_field( name = 'Cache-Control' ).
    runtime->server->response->delete_header_field( name = 'Expires' ).
    runtime->server->response->delete_header_field( name = 'Pragma' ).
    Also check threads like
    Download BSP data into Excel
    export bsp-table to excel
    Export BSP Table to Excel
    Eddy
    PS. Reward useful answers and earn points yourself

  • How to delete an operation from order using the bapi

    Can somebody please tell me how to delete an operation from order using the bapi
    BAPI_ALM_ORDER_MAINTAIN.
    Following was the test data for the BAPI.
    000000 OPERATION DELETE 0000040052810070
    000000 SAVE 0000040052810070
    Even I tried entering the operation table. The BAPI control ends fine, but when I check the order using IW32, the operation still exists.
    So, can you please tell me where Iam going wrong.

    Hi Subash Mohanvel,
    Check bapireturn parameter of the bapi BAPI_ALM_ORDER_MAINTAIN after execution of the code , and if there is no error message in the return table then call bapi_Transaction_commit.
    Unless you call this database saving of the records/values will not get reflected in the system.
    Hope that helps.
    Regards
    Kapadia
    ***Assigning points is the way to say thanks in SDN.***

  • How to set Border in the Excel using UTL_FILE ?

    Hi all,
    Any one aware of
    How to set Border in the Excel using UTL_FILE ?
    Am doing excel creation from a stored procedure.
    Thanks
    Dora

    Hello Dora,
    if you need more than simple csv: at Re: How to save a query result and export it to, say excell? you can find links to different solutions. At least the package behind the second link supports defining your own formats (and has a tutorial how to do it).
    Regards
    Marcus

  • Exporting Design steps of Business Process Components from QC to excel using macro

    I want to export design steps from Business Process Components from QC to excel using macro. CAn anyone please help me with that.
    Thnx, Sanket

    Post Author: swat
    CA Forum: Exporting
    Hi,
    Of what i gather from ur scenario...this is what i did in one of my reports.
    I had to use two subreports and they had to occupy one cell each, in line with other fields.
    To obtain that,all the fields required in the subreport i put them into a text box.Therein restricting the fields to the txt box only...
    Then import that sub-report as it is.
    It worked for me....
    try out...
    All this only if've understood u right...

  • How to Avoid Empty Space in Excel Export , while using SubReport.

    We have a sceneraio where we have parent child relationship and we are using the SubReport Concept to map the child data by taking input parameter from Parent Report.
    The RPL/HTMl viewer , PDF works fine, but  when we export data into excel empty rows are comming.
    Could  you please suggest how can we avoid empty space in Excel Export.
    we have kept the cell (width and height ) same as SubReport Width and height.

    Hi SubhadipRoy,
    According to your description, did you use separate subreport to display the data rather than insert subreport in tablix?
    Based on my test, if we are use separate subreport to display the data in the report, when we export to Excel we will get an additional row. We can adjust the minimum gap between tablix and subreport to work around the issue. In SSRS 2012, if we paste tablix
    and subreport without empty space in report design, it will not display the additional row. You can try to put the tablix and subreport in a rectangle to resolve the issue. 
    Reference:
    http://stackoverflow.com/questions/20367960/remove-additional-column-from-exporting-to-excel-from-ssrs
    There is a screenshot for your reference:
    If the issue is persist, please elaborate the issue for further investigation.
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • ADF Desktop Integration : How to delete the table in Excel?

    Hi,
    I am using Jdev 11.1.1.3.0 and Excel 2007 for Oracle ADF DI, I had created an ADF table using pageDef file in the excel. Now I wanted to delete that table and use a different pageDef file.
    I could not find a way to delete that table.
    I deleted full row of tables and then I used different pageDef file and created a new adf table. But when I am running this version of excel, I am getting runtime exception and excel is getting corrupted.
    My question how to delete the table not corrupting the Excel.
    Thanks
    Pavan

    Pavan,,
    Welcome to OTN.
    You can delete the table by selecting the top left column (of the table) and then select delete from the ADFdi tab.
    Refer the documentation for more info.
    http://docs.oracle.com/cd/E17904_01/web.1111/e10139/get_start_dev_tools.htm#ADFDI608
    -Arun

  • How to delete empty Last Import albums on Ipad2

    This is both a question and a partial solution to anyone who has found empty Last Import albums on their Ipad2 after upgrading to IOS 5.1.  I ended up with three Last Import albums on my Ipad under the Photos App after the upgrade to 5.1 and Iphoto app.
    I could not delete them no matter what I tried.  Even turned off Photo sync in Itunes and had it remove all photos from the Ipad and the empty folders are still there.
    I ended up trying a round about way of getting rid of the empties.  I reasoned that the Camera Connection kit had created this mess and maybe it could fix it.
    Solution:   (Only practical with a few empty folders)
    Shoot some photos with a digital camera using a SD card.
    Put the SD Card in the Camera Connection Kit and connect to the Ipad.  Import the images but keep them on the card.
    Disconnect the CCK and hook up to your Mac with Iphoto running. Import the images and delete from the Ipad when asked.
    Delete photos from Iphoto.
    Repeat several times and you should notice that each time one more Last Import album vanishes from the Ipad.
    Hope this helps someone else with this problem and Apple comes out with a better solution to this.

    I found a solution! I added a comment over on the shimworld blog (http://shimworld.wordpress.com/2011/11/02/how-to-remove-empty-photo-import-event s-on-your-ipad-2/#comment-18392), I'll repost it here:
    I ran into this same issue on my new iPad(3rd gen) after upgrading from iPad 2, I had a few hundred empty events(it took at least 30s of scrolling as fast as I could to reach the bottom). I use the camera connection kit as well as the EyeFI app to import photos constantly so it was a bit of a mess. I’m doing a road trip to SF area soon and needed space for new photos so I need to figure something out. After a bunch of digging around on the internet and looking into tools from my earlier jailbreaking days, I found a solution to do a full reset on the Photos.app. This does NOT require a jailbreak!
    First I imported all photos to my mac using Image Capture. Then I turned off iCloud’s PhotoStream, turned off photo syncing in iTunes and let a the iPad do a full sync and backup. Next I ran DiskAid and deleted the photo related folders under the File System -> Media area(see below). This removed EVERYTHING from the Photos.app. Then I rebooted the iPad. The Photos.app was empty just like on a new device! I snapped a couple pics with the camera and it created the camera roll, I turned PhotoStream back on, synced some photos from iTunes. Everything seems to be working great now, just like new!
    BEWARE: THIS WILL DELETE ALL PHOTOS STORED ON YOUR DEVICE in Photos.app!!! MAKE A BACKUP!!!!
    Connect iOS device with USB and fire up DiskAid. In DiskAid click File System, then click Media. READ WARNING and accept.
    Delete these folders:
    PhotoData (this has all the photos, database, etc synced from iTunes)
    DCIM (this is the camera roll)
    Photos (I think this is just the data to determine which iTunes library its synced with)
    PhotoStreamsData (iCloud Photo Stream data)
    Reboot iPad(probably not required but doesn’t hurt)
    Enjoy a fully reset Photos.app!
    DiskAid: I used v5.12 on my Mac Mini(10.7.3)
    http://www.digidna.net/products/diskaid

  • How to set Password protection in excel using java

    Dear all,
    I have no idea to write a java program that how to set password protection in excel. Please give me some solution using java tools. Thank a lot!
    Regards,
    kzyo

    Dear Bamkin ,
    I used your code and paste it in my program. The error is as the follow:
    Code:
         stmnt = c.createStatement();
                   String query = "select StudentNumber, Email, New_Email_Address from [Sheet1$] where Len(New_Email_Address) > 0";
                   System.out.println(query);
                   rs = stmnt.executeQuery(query);
                   stmnt.executeUpdate("SET PASSWORD=PASSWORD('Test')");
    Error:
    (Remark: Invalid SQL statement)
    java.sql.SQLException: [Microsoft][ODBC Excel Driver] �����I SQL ���q���G�a����'DELETE'�A'INSERT'�A'PROCEDURE'�A'SELECT' �� 'UPDATE' �B
         at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
         at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
         at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
         at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:288)
         at hk.gov.edb.util.ExcelHandle.updateNewEmail(ExcelHandle.java:414)
         at hk.gov.edb.core.AppMain.doUpdate(AppMain.java:369)
         at hk.gov.edb.core.AppMain$7.construct(AppMain.java:584)
         at hk.gov.edb.util.SwingWorker$2.run(SwingWorker.java:127)
         at java.lang.Thread.run(Thread.java:595)

  • How to delete cube old request by using abap code?

    Dear experts,
    Here is one thing need your help:
    We have one cube need to delete the old request. This cube is loaded daily and only need to delete the request of that month.
    I know there is one "Delete Overlap Requet" type in the process chain, but my concern is: in our DTP filter, different day the selection will have different values, let's say A and B, and A and B are not even overlap at all.
    So my question is:
    1. Can I still use "Delete Overlap Request" to delete the old request?
    2. If so, I see it can be implemented by abap routine, can anyone give me some sample code? Like how to delete request only in this month. And how to delete request whose selection is equal to a specific value.
    Note: one of the source cube is real time cube so can not delete the request from infopackage.
    Any post will be appreciated and thank you all for your time in advance!
    Regards.
    Tim

    Here is the intial code when I choose "Request Selection through Routine", please help me on how to choose the specific request and delete them in this routine.
    program conversion_routine.
    Type pools used by conversion program
    Global code used by conversion rules
    $$ begin of global - insert your declaration only below this line  -
    TABLES: ...
    DATA:   ...
    $$ end of global - insert your declaration only before this line   -
        InfoCube        = ZPC_DEL_REQ_ZBPS_C01
    form compute_ZPC_DEL_REQ_ZBPS_C01
      tables l_t_request_to_delete structure rsreqdelstruc
      using l_request like rsreqdone-rnr
      changing p_subrc like sy-subrc.
    *Insert Source Code to decide if requests should be deleted.
    *All Requests in table l_t_request_to_delete will be deleted
    *from Infocube ZPC_DEL_REQ_ZBPS_C01.
    *Add new requests if you want to delete more (from this cube).
    *Remove requests you did not want to be deleted.
    $$ begin of routine - insert your code only below this line        -
         loop at l_t_request_to_delete.
         endloop.
         clear p_subrc.
    $$ end of routine - insert your code only before this line         -
    endform.

  • How to delete empty element in popup list

    I have a question about a suspicious behaviour in Forms Builder 10.1.2.0.2.
    When I have a list object (pop up list) I can define some values in the attribute palette of the object.
    So you can set a shown name and a value behind. In this little window to set the items of the popup list you get automatically a white empty item at the end of the list. When I click now on this empty item (you do so, when you want to add an item) Forms Builder automatically adds an new empty item at the end.
    When I click this new empty item, Forms Builder adss another empty one ... and so on.
    It´s very suspicious because, when I end this dialog with "OK", it will be saved and when I open the form (over web) I have at the end of the list one, two (or more) empty elements in list.
    But I can´t delete this empty ones from the list in Forms Builder.
    So my question:
    how can I delete empty items in a popup list??
    I try it with hit "del" button at keyboard or delete the set value for the item (I hope Forms Builder delete items without value). But all does not help.

    Thanks jwh for this great solution! :)
    On my german keyboard it is:
    ctrl+< for deleting a line
    ctrl+> (= ctrl+shift+<) for adding a new line
    Thanks! :)
    I have another question (you can maybe help me, too?).
    On this popup lists you can have several items. When you open a form (via web) and the list has more than x items (maybe 5 or 6) the form shows a scroll bar on the right side.
    Is there any poosibility to set how much items has to show and only show a scroll bar when there are more items in the list?
    Or other way: set the maximum of shown items so big, that there will be no scroll bar.
    Message was edited by:
    ulfk

  • How to delete a database record by using EJB entity beans

    Hi, All,
    Does anyone know how to use entity bean to delete a database record? I have all the EJB entity beans created, including access beans to each. I can successfully create records, find and update records, however, I haven't find a way to delete records yet.
    Your response is appreciated.
    Cathy

    Please see EJB Forums for continue discussion on this subject.
    Reference titile: "how to delete database record by using CMP entity beans "

Maybe you are looking for

  • Problem with USB/External-HDD/etc... not writing?

    Hello... Recently I've been having a problem with my USB, and external harddrive. It seems that for some reason when I copy files to the device, they do not write. If I go and view the device contents on another PC, my files aren't there, but on this

  • Photoshop Album 2.0 - Can I change Photo shooting dates

    My friend gave me Photoshop Album 2.0 to help her keep track of her pictures.  Problem is, she didnt set her camera to the right date, so some of the pictures have a "shoot" date that is not correct.  For example, the camera may have imprinted June 1

  • How good is the java jdbc-odbc bridge in 1.4.0?

    Hi, Can anybody tell me whether this bridge (in the latest SE, 1.4.0) does things like ResultSet.UpdateRow()... i.e. jdbc 2.0 functionality? I keep getting an ArrayOutOfBounds exceptoin... if not, can anyone recommend a good, free driver for use with

  • JE template using Crystal Reports

    hi all, where can i find the system Journal Entry System Template. i have check Report and Layout Manager under Financials -->> Journal Entry i can only find PLD items, not a Crystal Report type. i am using 8.81 PL:04, if a download is available plea

  • Do Beats by Dre, work with the iPhone 5?

    For Christmas I want Beats, and I want to make sure they would work with my iPhone 5. So do they, please?