+ Reply to Thread
Results 1 to 4 of 4

add cell depending on value text on another cell

  1. #1
    Registered User
    Join Date
    06-04-2005
    Posts
    32

    add cell depending on value text on another cell

    Hi,

    I have no experience with programming with vba, but would like to do something that seemingly only with it can be done... I have an old version of excel 2002

    Depending on the value of all the cells from column B, I would like to add a cell between B en C, C becoming then D...

    In another script, I'd like as well to have a script that allows me to bring the content in column A to column C when it is not empty or not containing text that looks like a date (it looks like dd-mm-yy plus a space and one or 2 digits)

    It looks to me very complicated, but I guess some of you would find that very easy ;-)

    Thx anyway for any answer.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: add cell depending on value text on another cell

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    06-04-2005
    Posts
    32

    Re: add cell depending on value text on another cell

    I couldn't get the attacher to work, so I made a screenshot.

    Preparing it, I saw that it would be more complicated:
    when the cell in column A is containing text and no date, it should as well look at the value of the preceding cell in B.

    I think you'll understand seeing the image, I included raw data and filtered data in the sample.

    Thx

    sample.PNG
    Attached Images Attached Images

  4. #4
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: add cell depending on value text on another cell

    Doudou,

    I'm finding your description of the issue somewhat confusing. I wonder if you can can do an exercise for me. I want you to write a logical idea of what you're trying to achieve.

    This is called 'Psuedocoding'. For example:

    In sheetname "MyExampleSheet"
    For each Row in the sheet
    Examine Column A.
    If the Row in Column A is empty then move data in Column C to Column D
    Examine Column B
    If the Row in Column B = "Some data" then Move Data in Column B to Column E

    So this is basic loop. In even plainer English,

    In the sheet that I am working with, start from row 1 and look at every row in turn until the last row.
    For each row that I am looking at, examine the required column. If that column contains data, tell me what to do with it.
    Continue reviewing and manipulating the data until all rows have been completed.

    This kind of exercise will help you to structure your thoughts about how the data should be manipulated logically. It won't matter that you don't know how to code. If you can structure your request in this way, somebody like me or Norie may be able to provide the actual code you need.

    For example:

    Option Explicit
    Sub MyWorksheetTest()
    'Purpose: Loops through each row in an excel sheet and moves data from one column to another
    Dim dDate as Date
    Dim strMyValue as String

    Set wsht = ThisWorkbook.Worksheets("MyExampleSheet")
    With wsht
    For i = 1 to 20 ' Where 20 is the last row ' This for loop will cycle for each row from 1 to 20. You need a start row and an end row.
    dDate = .Range("A" & i)
    if dDate = "01/05/2016" then ' If the data matches your requirements then do the following
    .range ("D" & i) = .range ("C" & i) ' Copy Column C to Column D for the row
    .Range("C" & i) ="" ' Make nothing
    End if
    Next i
    End with
    End Sub

    Hope this helps.

+ 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. Display a value or text in a cell depending on value in another cell
    By zoboran in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-10-2013, 10:49 AM
  2. [SOLVED] populate a cell with text depending on whether another cell has a value.
    By sheffieldlad in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-09-2013, 07:28 AM
  3. Replies: 4
    Last Post: 11-28-2012, 05:31 AM
  4. [SOLVED] Macro to change text in cell depending on the text in another cell in the same row
    By Misbah211 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-03-2012, 12:04 PM
  5. Change cell text depending on colour of a cell
    By wonderdunder in forum Excel General
    Replies: 3
    Last Post: 09-22-2010, 11:31 AM
  6. Replies: 3
    Last Post: 08-18-2010, 02:29 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