+ Reply to Thread
Results 1 to 10 of 10

help advice needed

  1. #1
    Registered User
    Join Date
    10-20-2006
    Posts
    12

    help advice needed

    Hi

    I was hoping someone will be able to help me.

    I have a column in a sheet, like the following example

    steven
    1
    1
    1
    1
    1
    Bill
    2
    2
    2
    Chris
    3
    3
    3
    3
    3
    3
    3
    3

    So the persons name can be followed by an unlimited number of rows. I don't know whether it will make a difference but the persons name is in blue. I want to be able to fill the persons name down overwriting the numbers below, until the next persons name is reached.

    I am a complete novice, so any help whether a) it is possible, and b) how to go about it would be very much appreciated.
    Last edited by stevencarroll19; 10-20-2006 at 06:21 AM.

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Below macro will do the job ...

    Alt F11 Insert Module
    Copy the code in module ..

    Sub Names()
    Dim i As Integer
    Dim LastRow As Integer
    LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
    For i = 1 To LastRow
    Range("A" & i).Select
    If Len(ActiveCell.Value) = 1 Then
    ActiveCell.Offset(-1, 0).Copy
    ActiveCell.Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    End If
    Next i
    End Sub


    HTH
    Cheers
    Carim

  3. #3
    Registered User
    Join Date
    10-20-2006
    Posts
    12
    hi thanks for your help but i am getting an error message

    I have done as you said but when i run it it says

    run time error '6'

    overflow

    hope you can help

    thanks

  4. #4
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,


    Have you checked the range ...
    Macro runs on column A, adjust to your needs ...

    Carim

  5. #5
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Copying name over numbers

    You can also do so:

    Dim i As Integer
    Dim LastRow As Integer
    LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row

    nameToUse = ""
    myRange = "a1:a" & LastRow
    For Each myCell In Range(myRange)
    If IsNumeric(myCell) Then
    If nameToUse <> "" Then
    'here I put the name on cells
    myCell.Value = nameToUse
    End If
    Else
    'here I store the name
    nameToUse = myCell
    End If

    Next

    Regards,
    Antonio

  6. #6
    Registered User
    Join Date
    10-20-2006
    Posts
    12
    Hi

    Thansk for your replies

    I think my original example wasnt a very good one

    Rather than numeric, the cells under each persons name contain text. The column is indeed A as the first anser guessed

    for example

    Steven
    Not Blocked
    Not Purchased
    Not Purchased
    Mike
    Not Purchased
    Not Purchased
    Not Purchased
    Not Purchased
    Not Purchased
    Chris
    Allowed
    Not Blocked
    Not Blocked

    Sorry if i misled you at all

    Thanks

    Steven

  7. #7
    Registered User
    Join Date
    10-20-2006
    Posts
    12
    Hi again,

    can anyone help me at all?

    Your help will be very much appreciated

    many thanks

    Steven

  8. #8
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Is it a process you will have to repeat ?

    What are all the different possibilities of strings below the first names ?

    Carim

  9. #9
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    The trouble with what you are asking is that you have to be able to get the VBA code to differentiate between a name and the other text you have in your cells. You will need to provide a fool proof method of doing this. Now you mentioned that the names are in blue, so we could use that to our advantage.

    the following code relies on the name being BLUE as per the description when you hover over the coloured swatches. If this is not the colour of your text, then you will need to change this line

    If Selection.Offset(X, 0).Font.ColorIndex = 5 Then

    to the colorindex that refers to the colour of your names



    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    10-20-2006
    Posts
    12
    Thanks

    the code works on smaller reports

    but for larger ones I'm getting an error code 6

    'Overflow'

    Last edited by stevencarroll19; 10-30-2006 at 12:14 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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