Enter Remaining Values From RangeB into Range A

pwill

Active Member
Joined
Nov 22, 2015
Messages
406
Hi can anyone help with vba code?​

I have two ranges A and B that mirror each other with headers A-G

range A "T5:Z7" sheet1
range B "AC5:AI7" sheet1

range B calculates values from another sheet and range A keeps a record of remaining values

when I have remaining values anywhere in 'range B' I want record them at the same position in 'range A' until all cells in range A are filled with values from range B by adding a line of code to commandbutton1

ie

Before

TUVWXYZAAABACADAEAFAGAHAIAJAK
1
2
3RngA recorded recordsRngB Remaining values
4ABCDEFGABCDEFG
5188
622499200
71055177188
8
After
TUVWXYZAAABACADAEAFAGAHAIAJAK
1
2
3RngARngB
4ABCDEFGABCDEFG
5188
622200499
71055177188
8

<tbody>
</tbody>


Any help would be appreciated

Regards

pwill
 
Last edited:

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try:

Code:
Sub macro1()
    Dim rng As Range, lr As Long
    lr = 0
    For Each cell In Union(Range("T1:Z1"), Range("AC1:AI1"))
        cell.Activate
        If lr < Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row Then
            lr = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row
        End If
    Next
    Set rng = Range("AC1:AI" & lr)
    For Each cell In rng
        If cell.Value2 <> "" Then
            cell.Activate
            If ActiveCell.Offset(, -5).Value2 <> "" Then
                   ActiveCell.Offset(, -5).Value2 = ActiveCell.Value2
                   ActiveCell.ClearContents
           End If
        End If
    Next
End Sub
 
Last edited:
Upvote 0
Assuming your values are constants (that is, there are not formula in "RngB Remaining values"), and assuming the location they are to be move to is always going to be empty in order to receive them, then I think this "simple" loop should work...
Code:
[table="width: 500"]
[tr]
	[td]Sub MoveRemainingValues()
  Dim Ar As Range
  For Each Ar In Range("AC5:AI" & Columns("AC:AI").Find("*", , xlFormulas, , xlRows, xlPrevious, , , False).Row).SpecialCells(xlConstants).Areas
    Ar.Cut Ar.Offset(, -9)
  Next
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
Thanks for your reply's,

KolGuyXcel didn't work? but Rick Rothstien works fine, much appreciated :)

pwill
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,644
Messages
6,125,991
Members
449,278
Latest member
MOMOBI

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top