+ Reply to Thread
Results 1 to 17 of 17

VBA programming: auto change cell texts based on one specific value, how to do it?

  1. #1
    Registered User
    Join Date
    04-14-2020
    Location
    Estonia
    MS-Off Ver
    2017
    Posts
    9

    VBA programming: auto change cell texts based on one specific value, how to do it?

    Hei!

    I would like to auto change the cell texts based on one specific value. How I can do that?
    I have different data what need to be changes based the one specific value.

    Example: I have cell C5, specific value (there can be six different values)
    and if I fill the C5 cell then it will auto change the other data in other cells.

    If the cell C5 = A then
    range (...) = ...
    range (..) = ...
    Elseif the cell C5 = B then
    range...
    range..
    Elseif teh cell C5 = C then (I get an error)

    But I canīt add the third specific value?

    I tried it with if multiple condition function. If I tried to add the third specific value I get an error: expected list separator or.

    Can anyone help me out, how can I finish the macro?

  2. #2
    Valued Forum Contributor
    Join Date
    01-14-2013
    Location
    Austria
    MS-Off Ver
    2016 / 2019
    Posts
    339

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    provide a sample file including your code

  3. #3
    Registered User
    Join Date
    04-14-2020
    Location
    Estonia
    MS-Off Ver
    2017
    Posts
    9

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    Attached sample for this part!
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    01-14-2013
    Location
    Austria
    MS-Off Ver
    2016 / 2019
    Posts
    339

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    Please Login or Register  to view this content.
    ==> change to
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-14-2020
    Location
    Estonia
    MS-Off Ver
    2017
    Posts
    9

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    Thanks

    Perhaps you can help me with another thing, Iīm not sure how to do it. Put I would like to have in excel same kind of insert picture box as it is in powerpoint.
    For example the box into where I can add picture(s) and the picture will automatically fit (match) in the size of the box.
    I tried it with textbox but it doesnīt work that way. Iīm still have to match the picture manually.
    Is there some kind of opportunity how to do it?

  6. #6
    Valued Forum Contributor
    Join Date
    01-14-2013
    Location
    Austria
    MS-Off Ver
    2016 / 2019
    Posts
    339

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    There is an ActiveX Element called image.
    you can define the size of this element and also define the picture which should be shown.
    An exact fit is only possible if the ratio of x and y are the same for frame and picture (I think it is the same in PPT).
    you have the possibility for zoom, clip and stretch.

  7. #7
    Registered User
    Join Date
    04-14-2020
    Location
    Estonia
    MS-Off Ver
    2017
    Posts
    9

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    Thank you a lot I will learn a bit about ActiveX Element. I donīt know would this work, because I have to copy in those boxes tables what game from another software, there are ex. some calculations and charts etc.

    I have trouble with one more thing:

    I have in the same file tables (these are not on the same sheet, but on another sheet).
    How can I copy these tables automatically if i change the same cell.value (as I use the if then else macro). The table are different for each product, and to change them manually, it is quite possible that something go wrong.
    Can I use the same macro if then else, but how?

  8. #8
    Valued Forum Contributor
    Join Date
    01-14-2013
    Location
    Austria
    MS-Off Ver
    2016 / 2019
    Posts
    339

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    almost everything is possible but most time some restrictions exists.
    can you provide a sample file ? If there are sensitive data in, then overwrite/randomize them.

  9. #9
    Registered User
    Join Date
    04-14-2020
    Location
    Estonia
    MS-Off Ver
    2017
    Posts
    9

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    Right now I have the tables on another sheet (the program should choose right table if I change on specific value and run automatically as the table in above (in my sample it is C18). I copied one table also to another sheet.
    I have six different products so the tables are exactly product-based (the specific indicates etc).
    How is it the best way to do that?

    The other table works perfectly and run automatically
    Attached Files Attached Files

  10. #10
    Valued Forum Contributor
    Join Date
    01-14-2013
    Location
    Austria
    MS-Off Ver
    2016 / 2019
    Posts
    339

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    I cannot understand what is written in your workbook (not able to speak or read your language) and I did not find any pattern to be able to connect the table on sheet Blankett to be visible on sheet Leht1.

    can you please provide how it should look like when you select the right value (which is it?) in C18?
    To complete table or only a part of the table?

  11. #11
    Registered User
    Join Date
    04-14-2020
    Location
    Estonia
    MS-Off Ver
    2017
    Posts
    9

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    It should copy/paste the right table, in my sample there is at the moment only one table. If the C18 value = S1 then it should automatically copy/paste the right table from sheet Leht1 to A29 and below (I can specify the size of cells where the tables should fit). If the C18 value = H1 then it should choose the table what is correct for H1.

  12. #12
    Valued Forum Contributor
    Join Date
    01-14-2013
    Location
    Austria
    MS-Off Ver
    2016 / 2019
    Posts
    339

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    have a look into the attached file
    I added a second table for test only to see it work if something changes
    I named the data area to "tbl_" & cell value ( "tbl_S1", ...) but it is not a table (only named range)

    Please Login or Register  to view this content.
    you should do the same with your already available data change in your other function If_Multiple_Conditions
    provide your different data also as tables or named ranges then it is easier to modify specific data and also add additional data

    you should also use a dropdown box for your cell C18

    cheers
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    04-14-2020
    Location
    Estonia
    MS-Off Ver
    2017
    Posts
    9

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    Hi!

    Thank you, I made same tables for other products and this works perfectly, thank you a lot, you saved my day I added also the dropdown box and picturelookup function, what all works as I wanted.

    Iīm little-bit trouble with this activex image control thing. I have never used it and as I learned about the function, how it suppose to work but actually I donīt have any ideas how I should do that. I added a photo, how it should look like in excel (the graphs will come another program, so I thought perhaps there is some better way to add them into this excel file, so I donīt need to use that much time for designing it every time). The every graphs are separate and I have them about 4 A4 pages. They wonīt fit into one page and to design the all pages, perhaps there is some opportunity to make it work? Attachment 673847

  14. #14
    Valued Forum Contributor
    Join Date
    01-14-2013
    Location
    Austria
    MS-Off Ver
    2016 / 2019
    Posts
    339

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    I cannot open your attachment
    Invalid Attachment specified
    . May be you zip it and include the zip-file?

  15. #15
    Registered User
    Join Date
    04-14-2020
    Location
    Estonia
    MS-Off Ver
    2017
    Posts
    9

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    Itīs jpg file from my final report.
    Attached Images Attached Images

  16. #16
    Valued Forum Contributor
    Join Date
    01-14-2013
    Location
    Austria
    MS-Off Ver
    2016 / 2019
    Posts
    339

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    I understood that from other programs you get pictures you want to insert (jpg, tiff, ...)

    Then there may be more possibilities but my first ideas
    1) if the pictures are already in a size (ratio of length to witdh) then the easies way is
    - start the macro recorder to insert a picture (ribbon "Insert / Insert a picture / This device" and select one)
    - place it where you need it
    - change the size (select the corner to resize and keep ratio). there is no possibility to clip, zoom, ... etc as it would be possible for the ActiveX version
    - stop the recorder

    Now the file name is hard coded. If it must be dynamic you have to add a file picker dialogue or you write the paths for all pictures in some cells and get the names from there.
    this you have to do for all 6 pictures, with adoption of top and left property to get them on the right position
    Reading in the file names can be handled via button or direct macro call

    2) you start the macro recorder
    - you place the ActiveX frames with the size you need it
    - in the property window there is one entry with "Picture" (None). clicking on the button (three dots) will open a dialog window and you can select a file
    - you may not see something if the original pictuere is to huge, so change Property PictureSizeMode to most probably to fmPictureSizeModeZoom
    - stop recording (or play with some of the properties to get best result)

    then you have to do the same as above

    hope this helps,
    cheers

  17. #17
    Registered User
    Join Date
    04-14-2020
    Location
    Estonia
    MS-Off Ver
    2017
    Posts
    9

    Re: VBA programming: auto change cell texts based on one specific value, how to do it?

    Thanks Iīll try this!

+ 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. [SOLVED] insert empty rows after a cell containing specific texts.
    By barrowinfurnace in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-19-2019, 03:57 PM
  2. VBS Help to Auto Refresh Pivot Tables when data or specific cell values change
    By kwoltman in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-13-2017, 06:55 PM
  3. [SOLVED] Highlight specific texts in a cell with red bold font using VBA
    By farrukh in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-06-2017, 10:38 AM
  4. Replies: 3
    Last Post: 04-05-2017, 04:01 AM
  5. Extracting first number from numbers and texts in specific cell
    By macky18 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-25-2014, 08:53 AM
  6. [SOLVED] VBA Help needed to fill cells with some specific texts based on multiple conditions
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-18-2014, 12:52 PM
  7. [SOLVED] Message box pup up when cell contains specific texts
    By kleevin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-02-2013, 02:03 AM

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