Adding into a Series of Numbers

999HelpPlease

New Member
Joined
Jul 16, 2014
Messages
35
10 - Example Number

Let's say I have a spreadsheet and I wanted to add cell example "H1" to the entire column of H.

How do I write this in VBA?

The number 10 could change but the 10 would already be added and it could stay that way.

I am confused on how to write this one. Can anyone give me some suggestions?
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,416
Office Version
365
Platform
Windows
I am sorry, your post is very confusing.
Can you try rephrasing it?
 

999HelpPlease

New Member
Joined
Jul 16, 2014
Messages
35
I will try. If you look at the spreadsheet below. What I want to do is take the 10 and add it into every number in that column. So it would add it to all the 3's and they would become 13. Does this help.

10
123
123
123
123
123
123
123
123
123

<colgroup><col width="64" style="width:48pt" span="3"> <tbody>
</tbody>
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,416
Office Version
365
Platform
Windows
OK. Where is this number coming from?
Will it be a cell on a sheet, or an input asked for when a macro is run?

Note, that if it is a cell on your sheet, this can be done very easily without any VBA.
Just highlight the number and click Copy
Then, highlight the whole range you want to paste it to
Then right-click and select Paste Special -> Add -> OK
 
Last edited:

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,416
Office Version
365
Platform
Windows
Here is what a VBA solution would look like, adding the value from K1 to all the cells in column H, down to the last one.
Code:
Sub MyCopyMacro()

    Dim lastRow As Long
    
'   Find last row in column H
    lastRow = Cells(Rows.Count, "H").End(xlUp).Row
    
'   Add value from K1 to column H
    Range("K1").Copy
    Range("H1:H" & lastRow).PasteSpecial Paste:=xlPasteAll, Operation:=xlAdd, SkipBlanks:= _
        False, Transpose:=False
    Application.CutCopyMode = False

End Sub
If you are looking for an Input solution, just incorporate the same InputBox methodology we discussed in your other thread.
 

Forum statistics

Threads
1,081,530
Messages
5,359,347
Members
400,524
Latest member
Excelbat

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top