new to macros

JerVD

New Member
Joined
Nov 8, 2018
Messages
8
hey all

I'm completely new to macros in excel. I'm trying to make a button on my sheet that takes the number in one cell (will be formatted as a currency and is being calculated using a formula.) and puts it in the next available cell in a column.

[TABLE="width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD][/TD]
[TD]Date[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]$100.00[/TD]
[TD][/TD]
[TD]1/12
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]2/12[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3/12[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]4/12[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

first press A1 to B1
next press A1 to B2
next press A1 to B3
and so on

I appreciate the help with this
I'm on Excel 2016 Mac

Jer
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Attach this code to a button.

Code:
Option Explicit


Sub Jer()
    Dim lr As Long
    lr = Range("B" & Rows.Count).End(xlUp).Row
    If Range("B1") = "" Then
        Range("A1").Copy
        Range("B1").PasteSpecial xlPasteValues
    Else
        Range("B" & lr + 1).PasteSpecial xlPasteValues
    End If


End Sub
 
Upvote 0
I modified previously posted script.

That script only did copy if..

Try this:
Code:
Option Explicit
Sub Jer()
'Modified  12/27/2018  8:38:34 PM  EST
    Dim lr As Long
    lr = Range("B" & Rows.Count).End(xlUp).Row
    Range("A1").Copy
    If Range("B1") = "" Then
        Range("B1").PasteSpecial xlPasteValues
    Else
        Range("B" & lr + 1).PasteSpecial xlPasteValues
    End If
Application.CutCopyMode = False
End Sub
 
Upvote 0
hey so I am getting a compile error.
"x1Up" is highlighted.

I did change the cell references to the actual ones I'm using in my sheet.

I ended up with this.


Dim lr As Long
lr = Range("I" & Rows.Count).End(xlUp).Row
Range("J8").Copy
If Range("I25") = "" Then
Range("I25").PasteSpecial xlPasteValues
Else
Range("I" & lr + 1).PasteSpecial xlPasteValues
End If
Application.CutCopyMode = False


J8 is the cell im trying to copy from
and I25 thru I55 is where im trying to paste.

what did I mess up?
 
Upvote 0
Why did you ask for:

first press A1 to B1
next press A1 to B2
next press A1 to B3

But now ask for something completely different?
 
Last edited:
Upvote 0
This script works for me
hey so I am getting a compile error.
"x1Up" is highlighted.

I did change the cell references to the actual ones I'm using in my sheet.

I ended up with this.


Dim lr As Long
lr = Range("I" & Rows.Count).End(xlUp).Row
Range("J8").Copy
If Range("I25") = "" Then
Range("I25").PasteSpecial xlPasteValues
Else
Range("I" & lr + 1).PasteSpecial xlPasteValues
End If
Application.CutCopyMode = False


J8 is the cell im trying to copy from
and I25 thru I55 is where im trying to paste.

what did I mess up?
 
Upvote 0
Why did you ask for:

first press A1 to B1
next press A1 to B2
next press A1 to B3

But now ask for something completely different?

Sorry I figured it was easier to show what I wanted on a simple table rather than on what I was actually working on. I always try to decode the things people help me with so I can learn. so I take what people help me with and try to rebuild it for myself in the situation I want it for.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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