Auto-Fill values

Saher Naji

Board Regular
Joined
Dec 19, 2019
Messages
76
Office Version
  1. 2013
Platform
  1. Windows
Hello

Thanks in advance,

I tried to crate a formula, but the problem I have to make the formulas fixed by $ symbol, this will cost me a long time

What I'm looking for is a formula or a macro to do this thing automatically each time, because I have hundreds of rows, and the number of boxes (columns) is not fixed, some times I have 50 boxes or more.

Check the attached screenshot please,

Best.
 

Attachments

  • Screenshot.png
    Screenshot.png
    56.1 KB · Views: 13

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Change "$A$2" to just "$A2" so the row number updates as you fill down. When you fill across columns, the $A will stay static.
 
Upvote 0
VBA Code:
Option Explicit

Sub Boxes()
    Dim lr As Long, lc As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    Dim i As Long
    For i = 2 To lr
        lc = Cells(1, Columns.Count).End(xlToLeft).Column
        Range(Cells(i, 2), Cells(i, lc)).Value = Range("A" & i)
    Next i
End Sub
 
Upvote 0
VBA Code:
Option Explicit

Sub Boxes()
    Dim lr As Long, lc As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    Dim i As Long
    For i = 2 To lr
        lc = Cells(1, Columns.Count).End(xlToLeft).Column
        Range(Cells(i, 2), Cells(i, lc)).Value = Range("A" & i)
    Next i
End Sub
This is what I want,
it just need small edit to be perfect, I tried to do it myself by I couldn't, (Check this new attachment please)
and how could I use it for tens of files?
Could I save it as a separated file, and import it when I need it?

Thanks a lot ♥
 

Attachments

  • Screenshot2.png
    Screenshot2.png
    25.5 KB · Views: 12
Upvote 0
Don't understand your picture. Suggest you explain step by step what you want. It is always a good idea to show us an actual representation of what you want from the beginning. Because what you have done is change up what the expected results are and causes more work -- tell us up front what it is that you need. Also, if you use the XL2BB function you can attach a piece of the file and we don't have to guess at what formatting is in a picture. We cannot manipulate data that is in a picture and since your "new" request appears to be more complicated, a sample using XL2BB is the way to go. Also, show us what the expected results are.
 
Upvote 0
thank you, in fact your code is working very well, but I need to apply it to the original document, this is the first time I tried using XL2BB, I hope it works
Sample File Excel-formula included.xlsx
GHIJKLMNOPQRSTUVWXYZAAAB
1
2
3
4Prep TypeWho will label?Expected QTYUnits per CaseNumber of CasesBoxed Case QTYBox 1 - Case QTYBox 2 - Case QTYBox 3 - Case QTYBox 4 - Case QTYBox 5 - Case QTYBox 6 - Case QTYBox 7 - Case QTYBox 8 - Case QTYBox 9 - Case QTYBox 10 - Case QTYBox 11 - Case QTYBox 12 - Case QTYBox 13 - Case QTYBox 14 - Case QTYBox 15 - Case QTY
5--None Required1330010
6--None Required115510
7--None Required1400010
8--None Required199910
9--None Required130010
10--None Required1444510
11--None Required1232310
12--None Required123432410
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Tabelle1
Cell Formulas
RangeFormula
L5:L12L5=SUM(N5:AG5)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L5:L12Expression=ISERROR(L5)textNO
L5:L12Expression=OR((L5 <> K5), (INT(L5) <> L5))textNO
N16:CG984,O5:CG15Expression=OR(AND(NOT(ISNUMBER(N5)), NOT(ISBLANK(N5))), (N5 < 0))textNO
N16:CG984,O5:CG15Expression=(INT(N5) <> N5)textNO
Cells with Data Validation
CellAllowCriteria
O5:AB31Whole number>=0
N16:N31Whole number>=0



No what I want is to apply your VBA code to this new workbook,
 
Upvote 0
You have provided all the formatting but none of the data. Still need to understand what you want to do and the expected results. Please explain. Post #7 is of no hlep.
 
Upvote 0
You have provided all the formatting but none of the data. Still need to understand what you want to do and the expected results. Please explain. Post #7 is of no hlep.
Sorry for that,
I"m going to explain from the beginning

what I want:

just to take the values from each row in column J and put them in each respective cell of rows N until the end of columns (in this case AB)

while being able to account for an infinite amount of rows in column J and total amount of columns, as those values change depending on how many products and how many boxes will be shipped

the script then just has to be easily applied to new sheets of the same format

So in short words, it is repeating the values from Column J to the columns from N to the last column headed by Box #-Case QTY

I hope that's my point is clear now

Thanks
 
Upvote 0
Ok. Got it now. Thanks for being clear.

VBA Code:
Sub Boxes()
    Dim lr As Long, lc As Long
    Application.ScreenUpdating = False
    lr = Range("J" & Rows.Count).End(xlUp).Row
    Dim i As Long
    For i = 2 To lr
        lc = Cells(4, Columns.Count).End(xlToLeft).Column
        Range(Cells(i, 14), Cells(i, lc)).Value = Range("J" & i)
    Next i
    Application.ScreenUpdating = True
End Sub

Create a Personal.xlsb file and store this in that file. Google Ron deBruin Personal.xlsb and follow his instructions for creating and using in multiple files.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,217
Members
452,619
Latest member
Shiv1198

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