+ Reply to Thread
Results 1 to 4 of 4

Macro to copy value in empty cells

Hybrid View

  1. #1
    Esrei
    Guest

    Macro to copy value in empty cells

    I have a macro that insert a line every time the value in C changes. Now I
    want to add that it must put in the new row in A the text that is in C in
    the row just under this row.
    So This would be like a heading.
    Hope I am not too fuzzy.

  2. #2
    Bernie Deitrick
    Guest

    Re: Macro to copy value in empty cells

    Esrei,

    Post your old code.

    HTH,
    Bernie
    MS Excel MVP


    "Esrei" <Esrei@discussions.microsoft.com> wrote in message
    news:CF4BC70C-4635-417C-BD48-88CB07F0CAB6@microsoft.com...
    > I have a macro that insert a line every time the value in C changes. Now I
    > want to add that it must put in the new row in A the text that is in C in
    > the row just under this row.
    > So This would be like a heading.
    > Hope I am not too fuzzy.




  3. #3
    Esrei
    Guest

    Re: Macro to copy value in empty cells

    Bit of a long one working on a priclist to be coppied and made presentable
    from a DB.

    Sheets("Prys berekening").Select
    Range("A1:N1").Copy
    Sheets("Cust price list").Select
    Range("A16").PasteSpecial Paste:=xlValues, Operation:=xlNone,
    SkipBlanks:= _
    False, Transpose:=False
    Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Sheets("Prys berekening").Select
    Range("A2:N311").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Cust price list").Select
    Range("A17").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Range("B:B,D:E,G:G,N:N").Delete Shift:=xlToLeft
    Dim row_index As Long
    Application.ScreenUpdating = False
    lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
    For row_index = lastrow - 1 To 2 Step -1
    If Cells(row_index, "D").Value <> _
    Cells(row_index + 1, "D").Value Then
    Cells(row_index + 1, "D").EntireRow.Insert _
    (xlShiftDown)
    End If
    Next
    End Sub
    "Bernie Deitrick" wrote:

    > Esrei,
    >
    > Post your old code.
    >
    > HTH,
    > Bernie
    > MS Excel MVP
    >
    >
    > "Esrei" <Esrei@discussions.microsoft.com> wrote in message
    > news:CF4BC70C-4635-417C-BD48-88CB07F0CAB6@microsoft.com...
    > > I have a macro that insert a line every time the value in C changes. Now I
    > > want to add that it must put in the new row in A the text that is in C in
    > > the row just under this row.
    > > So This would be like a heading.
    > > Hope I am not too fuzzy.

    >
    >
    >


  4. #4
    Bernie Deitrick
    Guest

    Re: Macro to copy value in empty cells

    Esrei,

    Change

    For row_index = lastrow - 1 To 2 Step -1
    If Cells(row_index, "D").Value <> _
    Cells(row_index + 1, "D").Value Then
    Cells(row_index + 1, "D").EntireRow.Insert _
    (xlShiftDown)
    End If

    To:

    For row_index = lastrow - 1 To 2 Step -1
    If Cells(row_index, "D").Value <> _
    Cells(row_index + 1, "D").Value Then
    Cells(row_index + 1, "D").EntireRow.Insert _
    (xlShiftDown)
    Cells(row_index+1,1).Value = Cells(row_index +2,3).Value
    End If

    HTH,
    Bernie
    MS Excel MVP


    "Esrei" <Esrei@discussions.microsoft.com> wrote in message
    news:F32419EE-A582-492E-9DA3-5EEA6AE5442A@microsoft.com...
    > Bit of a long one working on a priclist to be coppied and made presentable
    > from a DB.
    >
    > Sheets("Prys berekening").Select
    > Range("A1:N1").Copy
    > Sheets("Cust price list").Select
    > Range("A16").PasteSpecial Paste:=xlValues, Operation:=xlNone,
    > SkipBlanks:= _
    > False, Transpose:=False
    > Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone,

    SkipBlanks:= _
    > False, Transpose:=False
    > Sheets("Prys berekening").Select
    > Range("A2:N311").Select
    > Application.CutCopyMode = False
    > Selection.Copy
    > Sheets("Cust price list").Select
    > Range("A17").Select
    > Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,

    SkipBlanks:= _
    > False, Transpose:=False
    > Range("B:B,D:E,G:G,N:N").Delete Shift:=xlToLeft
    > Dim row_index As Long
    > Application.ScreenUpdating = False
    > lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
    > For row_index = lastrow - 1 To 2 Step -1
    > If Cells(row_index, "D").Value <> _
    > Cells(row_index + 1, "D").Value Then
    > Cells(row_index + 1, "D").EntireRow.Insert _
    > (xlShiftDown)
    > End If
    > Next
    > End Sub
    > "Bernie Deitrick" wrote:
    >
    > > Esrei,
    > >
    > > Post your old code.
    > >
    > > HTH,
    > > Bernie
    > > MS Excel MVP
    > >
    > >
    > > "Esrei" <Esrei@discussions.microsoft.com> wrote in message
    > > news:CF4BC70C-4635-417C-BD48-88CB07F0CAB6@microsoft.com...
    > > > I have a macro that insert a line every time the value in C changes.

    Now I
    > > > want to add that it must put in the new row in A the text that is in

    C in
    > > > the row just under this row.
    > > > So This would be like a heading.
    > > > Hope I am not too fuzzy.

    > >
    > >
    > >




+ 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