Having a macro automatically adjust cells

PaytonsLearningVBA

New Member
Joined
Feb 7, 2022
Messages
5
Office Version
  1. 2021
Platform
  1. Windows
So I know when you have a formula, like A1 + B1 = C3, and you expand it down to row 2, it will automatically change it to A2 + B2 = C2.

Is there anything like this for macro's? I run this macro for every row I have, and I can have up to 50 rows. Currently I am adjusting 50 different codes.

I have the following macro and if I could get the underlined areas (anything with a 3) to automatically change depending on the row they are on, it would be a life changer.

VBA Code:
Private Sub CommandButton1_Click()

On Error GoTo ErrHandler

' SET Outlook APPLICATION OBJECT.
Dim objOutlook As Object
Set objOutlook = CreateObject("Outlook.Application")

' CREATE EMAIL OBJECT.
Dim objEmail As Object
Set objEmail = objOutlook.CreateItem(olMailItem)

With objEmail
.to = [U][C3][/U]
.Subject = "List of Needed Items - " & [U][A3][/U]
.Body = "Please see list of items needed for underwriting. " & [AA1] & [U][B3][/U] & [AA1] & "Thank you!" & [AB1]
.Display ' Display the message in Outlook.
End With

' CLEAR.
Set objEmail = Nothing: Set objOutlook = Nothing

ErrHandler:
'
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
So I know when you have a formula, like A1 + B1 = C3, and you expand it down to row 2, it will automatically change it to A2 + B2 = C2.

Is there anything like this for macro's? I run this macro for every row I have, and I can have up to 50 rows. Currently I am adjusting 50 different codes.

I have the following macro and if I could get the underlined areas (anything with a 3) to automatically change depending on the row they are on, it would be a life changer.

VBA Code:
Private Sub CommandButton1_Click()

On Error GoTo ErrHandler

' SET Outlook APPLICATION OBJECT.
Dim objOutlook As Object
Set objOutlook = CreateObject("Outlook.Application")

' CREATE EMAIL OBJECT.
Dim objEmail As Object
Set objEmail = objOutlook.CreateItem(olMailItem)

With objEmail
.to = [U][C3][/U]
.Subject = "List of Needed Items - " & [U][A3][/U]
.Body = "Please see list of items needed for underwriting. " & [AA1] & [U][B3][/U] & [AA1] & "Thank you!" & [AB1]
.Display ' Display the message in Outlook.
End With

' CLEAR.
Set objEmail = Nothing: Set objOutlook = Nothing

ErrHandler:
'
End Sub
So I didnt consider that the underline would print as code, so anything with __
 
Upvote 0

Forum statistics

Threads
1,213,552
Messages
6,114,278
Members
448,559
Latest member
MrPJ_Harper

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