Add code to represent a constant

dab1477

Board Regular
Joined
Jul 30, 2002
Messages
65
I want to add the following to my current code..

I want to find the first empty cell in Column A and enter the text "Final Inspection Days:".
I want to find the corresponding row in column Y and enter the value ".5"
I want to find the next empty cell in Column A and enter the text "Put-Away Days:"
I want to find the corresponding row in column Y and enter the value .25

The idea is that the following would ALWAYS occur as a constant at the END of my macro in colunms A and Y:
Fixed Days: .5
Put-Away Days: .25

My issue is that the above could occur at A20, Y20 and A21, Y21 one time, and then could be possibly be A27, Y27, and A28, Y28 the next. I don't know how to code this type of variable. I think I need to search for a cell as "is null", but am not sure how to so this.

Thanks in advance for any direction you can provide.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
dab1477,


Sample data before the macro:


Excel Workbook
AY
11
22
33
4
5
6
7
8
9
10
11
12
13
Sheet1





After the macro:


Excel Workbook
AY
11
22
33
4Fixed Days:0.5
5Put-Away Days0.25
6
7
8
9
10
11
12
13
Sheet1





Then you add more data:


Excel Workbook
AY
11
22
33
4Fixed Days:0.5
5Put-Away Days0.25
66
77
88
99
1010
11
12
13
Sheet1





After the macro:


Excel Workbook
AY
11
22
33
4Fixed Days:0.5
5Put-Away Days0.25
66
77
88
99
1010
11Fixed Days:0.5
12Put-Away Days0.25
13
Sheet1





Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


Code:
Option Explicit
Sub Test()

''You macro code goes here:


Dim NR As Long
NR = Range("A" & Rows.Count).End(xlUp).Offset(1).Row
Range("A" & NR) = "Fixed Days:"
Range("Y" & NR) = 0.5
Range("A" & NR).Offset(1) = "Put-Away Days"
Range("Y" & NR).Offset(1) = 0.25

End Sub


Then run the Test macro,
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

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