Comments on: How to insert and run VBA code in Excel - tutorial for beginners

This is a short step-by-step tutorial for beginners showing how to add VBA code (Visual Basic for Applications code) to your Excel workbook and run this macro to solve your spreadsheet tasks. Continue reading

Comments page 4. Total comments: 256

  1. Hi

    How can I write a code to do the following; If content in( W3:W395) is blank then delete the content in cell (G3:G395).

    Please help.

  2. Works perfectly! Thanks!

  3. I was wondering how I can modify the code to have all the excel files into 1 sheet instead of each individual sheets? Thank you

  4. Hello, i would like to change the address from where i am sending all the emails using the VBA macro excel. How do i change that? i dont know i am clear o not. Every time i send the emails from the VBA macro i would like to that "sender" appears a different email address than from where i am really am sending from.

  5. I am new so hope you can help.
    I would like to write code for registration of players and teams. How do I start please?
    Thanks
    John

  6. I want to develop a VBA code; let us suppose we have values like 1 2 3 4 5 in col A1 A2 A3 A4 A5 and other values like 6 7 8 9 10 in col B1 B2 B3 B4 B4 B5 and I want to write 1/6 2/7 3/8 4/9 5/10 in columns C1 C2 C3 C4 C5.

  7. Is it possible to call excell or word, without needing to specify which version (ie word 14, word 15 etc).

  8. in vba modules are saved by which extension

  9. Hi
    I am wanting to make a Commond Button that will insert a new row below the active cell and in the new row have formulas automatically populated.
    ie say active cell is D8 the press the Button and a new row is added to Row 9 which now includes the formula =sum(D7+B6) in the new cell C9 and the formula =sum(a2-a5) in cell e9.

    Thank

  10. Hi
    please I need assistance in converting the word into numbers

    example: let say the word (Rawad) and we have R = 10 , A = 1 , W = 700 and D = 3

    so the total of word Rawad must be 10 + 1 + 700 + 1 + 3 = 715

    thanks in advance

  11. Sir please forward Ur good comments that how I easily access what kind of book in Pakistan for learning VBA codes.

  12. How I made search button in excel VBA

  13. Hi - I am trying to create a Button in my sheet for a randomizer formula I set up. Basically, I have a list A:A of SKU names and B:B Random(1,5000)
    I want the button to auto-generate a 10 item SKU list that can be used for Inventory Cycle Counting. I set up the button but can not get any further with the visual basic script (newbie)

  14. dear sir\madam
    please tell me how to learn vba macros coding in excel sheets
    please help me

  15. I am failing to locate and make the Vb code

  16. Hi I cannot figure out how to have a row of possible 100 numbers that when I enter a number in cell A1 all the numbers move up one cell and the new number appears in B1 any help would be appreciated

  17. Hi,
    If i run the macro its successfully run ,while the next time i get an error . Kindly help what are the comment i need to use

  18. I performed the task but my spreadsheets did not merge what did I do wrong? All of the examples I followed but after the Alt F8 I was lost because it did not show what to do next or what I should be looking for.
    thanks

  19. Is import function runs in excel 2010? previously i created a code using import function to import .bas file into many excels sheets by running this code. now this in not working for excel 2010. can anybody please help me out here?

    1. Code:
      ActiveWorkBook.VBProject.VBComponents.Import ("C:\.....code.bas")

  20. I only need to remove carrigae returns in 1 column in my case Column H.

    How can I define the range to be H, and not the whole sheet?

    Thanks

  21. can you please tell how to copy paste from row1(sheet1) to any cell in sheet2.. and create a button for going to next row in sheet1

  22. VBA Macro for Change Case works well
    thank you very much

  23. Dear hoe to i set vba project in colum as(rohit kumar parasshar)in single colum i read in a video (by right click view code entir.excel.com

    (Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    ...................what i write heare
    End Sub)

  24. There are many mistakes in this post

  25. Im afraid horrible text and doesnt work

  26. This does not work

  27. I want to thank you for this code and tutorial. I don't write VB code and just need a quick solution to a problem and this resolved it. Thank you so much for your time and effort.

  28. Hi I am trying to create a template workbook for some data analysis. I have worked it up but now need to delete the data and save it as a template.

    I was just wondering if you have a workbook that has a VBA code attached if it is save as a macro enabled workbook do you have to add the code again when you reopen the workbook?

    Many thanks,

    Karen

    1. Karen:
      When you put the VBA in the module and saved it, the code would be in Excel. It would be available to be called from inside that workbook. Click Alt-F8 and you can see what code is available in that workbook. You should see the names of the modules you built and saved.

  29. Dear Sir / Madam.
    I have made a user form with 7 entries. I would like to have an Even number to become a Red font through my user form. So if the number is 346 then this number and all the other 7 boxes become a red font. Any help would be greatly appreciated. I just don't know what to write.
    Thanks and Kind regards
    Rob

  30. Thank you. Works perfectly!!

  31. Hi there,
    I tried your code but it doesn't do anything. No messages, nothing. What am I doing wrong?

    1. the same here!!

      1. Same for me

  32. I just want to say thank you for this fantastic, simple solution and for your awesome products in general.

  33. Hello,

    I want a code which is used to cut the rows having the red color and paste in another sheet and when color changes to white should transfer to same sheet (online spread sheets)

  34. IT IS VERY NICE THANK YOU

  35. Hellow Team,

    we need your help for VBA Coding in excel i don't know VBA coding how to start
    learning VBA Coding.

    1. Please help me to reference link to enhance skills I vBa

  36. Hello,

    Anyone who can assist me to provide a vba code on how to generate a responses that will be consolidated to another worsheet. Example, Response with "Will be included in the remediation" and "Partial Remediation" will be generated to the consolidated worksheet. Thanks

  37. Hi All,

    I would appreciate if someone could help me with some VBA coding I need to do. I am creating a userform for an excel document. It is quite simple but I really dont know how VBA coding works. I have 6 categories in my spreadsheet that have got to filled up in the form with numbers from 1/10 and then there is a comments box to for extra comments and a name box for the user name. finally it has 2 command boxes: Add company and close form.
    I have done the form now and given the usual names to the boxes such as:
    txtname
    cboquality
    cboprice
    cbostock
    cmdAdd
    cmdClose
    Can someone help me out with the code so that once the form is filled and the command box for add clicked all the information goes to the spreadsheet?

    It would be greatly appreciated

  38. Thank You! Big help!

  39. Hi!
    If i can't save file after i add this VBA code. It says that there is an error and Excel may able to save file by removing or repairing some features. Options are to click continue or cancel. When clicking continue it want to save file as another one, but in the end it says :file was not saved".

  40. Thank you so much. Big help.

  41. Excellent guideline. Thanks.

  42. This is excellent! I work at an I-Bank this is gold! Thank you Sir.

  43. Hi. I'm using a macro to combine multiple sheets in one excel workbook. Macro works but I keep getting a screen that asks me if I want to save or dont save I want to add this step into the macro, can someone please help?
    Thank you in advance.

    Sub GetSheets()
    Path = "\\>>>>>>>>>Extract for CD 20171027\"
    Filename = Dir(Path & "*.xls")
    Do While Filename ""
    Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
    For Each Sheet In ActiveWorkbook.Sheets
    Sheet.Copy After:=ThisWorkbook.Sheets(1)
    Next Sheet
    Workbooks(Filename).Close
    Filename = Dir()
    Loop
    End Sub

  44. Thank you so much! I've never added a macro and the steps were super easy to follow. Easy fix.

  45. how to use a module in a userform more than textboxes in same module
    please given the code and how to create a time symbol provide a number format example (1230 =12:30) in this code give to me
    thanks you

  46. bvfhj

  47. Hi,

    Please help me. I want to color cell background by comparing with cell value and one more cell value. Example: Col A (1:10) has values 0 & 1. Col B:E (B1:E10) has values of 1-100. Color B1:E10 if the value of cell >50 & A1 equal to 0. Total four colors and four conditions.
    1) A1:A10 = 0 then B1:E10 =50
    3) A1:A10 = 1 then B1:E10 =50

    I am able to create only for if B1:E10 >/<50.

    Thanks,
    Ravi

  48. I went through the steps above to add VBA code to my spreadsheet, however, when opening the macro, there is nothing listed for selection. Why is that? (In other words, I can see the information through ALT + F11, but when selecting ALT + F8, the macro is not there).

  49. I want to save a running total from a cell in Excel and wondered can this be done? I have a formula to put the total in a cell on a certain date but when the date has passed it clears the cell again and I want the running total on that date to be captured. My formaula in excel to capture data on a certian date is:- =IF(D2=(DATE(2017,6,11)),D3,0)

    Thanks for any info, Cheers Trev

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)