+ Reply to Thread
Results 1 to 3 of 3

Adding additional formatted cells using user input

Hybrid View

  1. #1
    Registered User
    Join Date
    11-08-2012
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    56

    Adding additional formatted cells using user input

    Hi guys

    I am creating a template for people to use for typing iSampleFile.xlsmn data.

    All the data have the same format, however they may vary in size.

    So, I would like to have a user define the number of specific entries he has, and then a VBA code create that number of cells and rows.

    So if a user has 25 item, all containing 40 items, Excel sets up the template having 25 columns, and 40 rows.

    I have attached a sample workbook. Looking at the excel file, the above stated should make sense.

    Thanks in advance.
    Danny

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Adding additional formatted cells using user input

    Here is a macro that could work for you. In order to have it run, you just need to name cell D4 as "Top_Left_Corner". The macro uses this named range as a reference.
    I've put the inputbox inside the Resize function. If the user click on Cancel, the macro will make no change in this dimension.
    Sub Expand_Table_To_User_Needs()
    '
        Range("Top_Left_Corner").Offset(-2, 0).Resize(2).Select
        Selection.Copy
        On Error Resume Next
        Range("Top_Left_Corner").Offset(-2, 0).Resize(2, InputBox("Enter number of columns needed", "NUMBER OF COLUMNS", 5, 300, 300)).Select
        Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
        Selection.DataSeries Rowcol:=xlRows, Type:=xlLinear, Date:=xlDay, Step _
            :=1, Trend:=False
        
        Range("Top_Left_Corner").Offset(0, -3).Resize(, 3).Select
        Selection.Copy
        Range("Top_Left_Corner").Offset(0, -3).Resize(InputBox("Enter number of rows needed", "NUMBER OF ROWS", 5, 300, 300), 3).Select
        Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
        Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
            Step:=1, Trend:=False
        Range("Top_Left_Corner").Select
    End Sub
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    11-08-2012
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: Adding additional formatted cells using user input

    That is just the thing I needed!

    Thx a lot.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. adding relative text to additional cells
    By roklock in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-09-2013, 02:51 PM
  2. Adding additional cells in IF formulas
    By JakeMann in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-20-2012, 06:59 AM
  3. Replies: 4
    Last Post: 04-22-2012, 07:55 AM
  4. Adding new sheet with User Input
    By CobraLAD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-10-2007, 11:45 PM
  5. Replies: 3
    Last Post: 03-25-2006, 12:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1