+ Reply to Thread
Results 1 to 3 of 3

copy column to the right if cell is not blank

  1. #1
    Registered User
    Join Date
    07-26-2022
    Location
    netherlands
    MS-Off Ver
    w10
    Posts
    2

    copy column to the right if cell is not blank

    Hi experts,

    I'm a complete newbie and have searched the internet for some time trying to find sample vba scripts helping me achieve my goal. In order to explain what I need, please also see the attached workbook. In short, I have a worksheet containg names of partipants in monthly activities. The number and names (can) change per month. I also have "monthly worksheets" which basically list the type of activities, the costs hereof and how the costs are divided over the participants.

    I now manually copy and transpose the participants from sheet1 to each monthly sheet. What I would like to do is automatically copy the individual names from sheet 1 (participants) to each monthly worksheet and when a "new" name is added in row 4 of a monthly-sheet (in the attached workbook for month Feb f) I would like to copy the contents of the preceeding column (from row 5 down to row 69). Actually since all columns are the same, it doesn't have to be the preceeding column but any column from H onward can be used. I can't find the correct formula to achieve this copy-action

    I do already use a vba script which deletes the column if a cell in row 4 turns up empty. Thus, the sheet for August (where a and b no longer participate and therefor return cells h4 and i4 empty) will, after executing the macro, delete the entire columns h and i. The following vba script is taken from the original workbook:


    Sub del()
    Dim i As Integer
    With Sheets("Jan")
    For i = 141 To 8 Step -1
    If IsEmpty(.Cells(4, i)) Or .Cells(4, i) = "" Then
    .Cells(4, i).EntireColumn.Delete
    End If
    Next
    End With
    End Sub

    I would be very grateful if anyone could help me automate the copy/transpose participants names and fill the costs/formula column in case a new participant starts participating.
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: copy column to the right if cell is not blank

    Hello and welcome to the forum.

    I can't help thinking you are approaching this from the wrong angle. Data capture and Data reporting require quite different treatments.

    A lot of people start by designing the form that they expect to see as the final report or which at first glance seems the best way of capturing data, and then wonder why it's so difficult to subsequently analyse and summarise or extract information from it.

    You should always capture data in a simple two dimensional table and worry about reporting information from it afterwards. Without exception doing this you will always be able to easily obtain management information. Rarely is this the case if you start the other way round.
    You will also throw open the whole wonderful world of the powerful Pivot table functionality.

    So before you get too far with this I'd create a single sheet database that contains the all your current columns, but with additional columns for Month, Activity and whatever stuff like "Prijs p.p." represents

    Your then is a much better position to report individual months, if that's your goal, either by one of the Filtering mechanisms or a Pivot Table.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    07-26-2022
    Location
    netherlands
    MS-Off Ver
    w10
    Posts
    2

    Re: copy column to the right if cell is not blank

    hi Richard,

    thanks for your prompt reply. You may very well be correct by stating the approach is all wrong, but in most cases (certainly mine) that wil be the case when adopting a file which has been around and used for quite some time and one wants to make it somewhat smarter instead of revising it as I lack those skills as well. The file is used to calculate each participants contribution fee and, based on attendance, how much he/she is due by the end of each month.

    Each month activities vary, so does the number of participants. That is why there's a monthly sheet with an overview of that month's activities and participants rather then having one "big" sheet with all columns, names, prices etc representing a full year. Although I see what you mean by the monthly reports (currently monthly worksheets) being more simple to generate in any which way I'd want, I'm concerned with the (eledged) complexity from an input side.

    In the end what this does (or belong to) is a financial reporting with A/R and A/P together with a P&L. The input is being done by the person of the foundation who is at a given time in charge of finance of the specific foundation. The way it was set up (i.e. per month) allows anyone with little to no skills to come up with a correct reporting. Changing this as you suggest would/could also require more skills or more control.

    I thought my goal to be achieved only required the skill to change participants names on the participants sheet (aside from entering the price per person per activity on a monthly-sheet). I did not think about a complete do-over of the existing sheets into one because I thought it would be not as clear due to the amount of data and limited screen size and therefor more room for error. I will give it some thought based on your recommendation though.

    KR Igor

+ 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. If cell in Column A is blank, copy contents from Column B, then delete
    By titikshu88 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-20-2021, 03:02 AM
  2. copy Formula & paste in same column next cell when previous column is not blank
    By sanjuss2 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-03-2020, 01:59 AM
  3. [SOLVED] Copy cell above to blank cells below till last filled cell of other column
    By abhinavbinkar in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-31-2018, 05:59 AM
  4. [SOLVED] Copy As Value into next blank cell in column
    By Rosco88 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-17-2018, 10:29 AM
  5. if blank in Column A copy cell B , F, K in that row
    By juanpmatheus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2013, 03:59 PM
  6. [SOLVED] To copy the same value in the next blank cell below it in a column
    By pksreela in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-28-2012, 10:22 AM
  7. HOW DO I COPY THE LAST NON BLANK CELL IN A COLUMN
    By Needles in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-16-2005, 02:05 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