Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8587497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:35:01+00:00 2026-06-11T22:35:01+00:00

I have the code working exactly the way I’d like to, however I don’t

  • 0

I have the code working exactly the way I’d like to, however I don’t want it to skip onto another column. I just want my macro to run inside column C then exit.
I am new to VBA in excel, so please pardon my faults.
Any help would be much appreciated.
Thanks in advance.

    Sub CopyValuetoRange()
'
' CopyValuetoRange Macro

Dim search_range As Range, Block As Range, last_cell As Range
  Dim first_address$
  Set search_range = ActiveSheet.UsedRange
  Set Block = search_range.Find(what:="*", _
    after:=search_range.SpecialCells(xlCellTypeLastCell), _
    LookIn:=xlValues, searchorder:=xlColumns, searchdirection:=xlDown)
  If Block Is Nothing Then Exit Sub

  Set Block = Block.CurrentRegion
  first_address$ = Block.Address
  Do
    Block.Select
    Selection.End(xlDown).Select
    ActiveCell.CurrentRegion.Rows(2).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.FormulaR1C1 = "=R[-1]C"

    'MsgBox "Next Block Range"
    Set last_cell = Block.Cells(Block.Rows.Count)
    Set Block = search_range.FindNext(after:=last_cell).CurrentRegion
  Loop Until Block.Address = first_address$ 'ActiveSheet.Range("C26").End(xlDown).Row


End Sub

Here is something I modified from something I found that will essentially do the same thing, however it puts the first cells value into all cells in the range. And this macro actually stays in Column C, since I found recently because it’s not a region, it’s a range.

Is there a way to change the following to add a formula to all cells in the range that points to the first cell in the range?

Sub Macro5()

    Dim Rng As Range
    Dim RngEnd As Range
    Dim rngArea As Range

        Set Rng = Range("C1")
        Set RngEnd = Cells(Rows.Count, Rng.Column).End(xlDown)
        If RngEnd.Row < Rng.Row Then Exit Sub

        Set Rng = Range(Rng, RngEnd)

        On Error GoTo ExitSub
        Set Rng = Rng.SpecialCells(xlCellTypeConstants)

        For Each rngArea In Rng.Areas
            rngArea.Value = rngArea.Cells(Rng.Rows.Count, 1).Value
        Next rngArea


ExitSub:
    ' Macro will exit here if the range is empty.

End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:35:02+00:00Added an answer on June 11, 2026 at 10:35 pm

    Here’s what I have, it’s not pretty but it works. I added a column on both sides then removed them after the macro went through the entire column:

    Sub CopyFirstCellInRangeInOneColumn()
    '
    ' CopyValuetoRange Macro
    Dim search_range As Range, Block As Range, last_cell As Range
      Dim first_address$
      ''
        Columns("C:C").Select
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        Columns("E:E").Select
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
      ''
      Set search_range = ActiveSheet.Range("D:D")
      Set Block = search_range.Find(what:="*", _
        LookIn:=xlValues, searchorder:=xlColumns, searchdirection:=xlDown)
    
      'Set search_range = ActiveSheet.UsedRange
      'Set Block = search_range.Find(What:="*", _
      '  After:=search_range.SpecialCells(xlCellTypeLastCell), _
      '  LookIn:=xlValues, SearchOrder:=xlColumns, SearchDirection:=xlDown)
    
    
      If Block Is Nothing Then Exit Sub
    
      Set Block = Block.CurrentRegion
      first_address$ = Block.Address
      Do
        Block.Select
        Selection.End(xlDown).Select
        ActiveCell.CurrentRegion.Rows(2).Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.FormulaR1C1 = "=R[-1]C"
    
        MsgBox "Next Block Range"
        Set last_cell = Block.Cells(Block.Rows.Count)
        Set Block = search_range.FindNext(After:=last_cell).CurrentRegion
      Loop Until Block.Address = first_address$ 'ActiveSheet.Range("C26").End(xlDown).Row
    
        Columns("C:C").Select
        Selection.Delete Shift:=xlToLeft
        Columns("D:D").Select
        Selection.Delete Shift:=xlToLeft
    
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this JQuery code working however I need to know whether how to
I have built a CSS navigation header, and it's working exactly the way I
I have this code working in C#: var request = (HttpWebRequest)WebRequest.Create(https://x.com/service); request.Method = GET;
In YUI I have following code working for mouse wheel. How do I make
I used to have this code working with my Tomcat server: HttpRequestBase targetRequest =
Need some regular expressions help. So far I have my code working to allow
I’m trying to issue web requests asynchronously. I have my code working fine except
this seems to be weird but it really happened. I have this code working
I have working code of js, it shows different div for selected option. <html>
We have the following code working for a complex rails form with checkboxes. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.