Find last Used Cell and more

chrismarek9

New Member
Joined
Mar 5, 2018
Messages
6
I have a sheet where the last row can be J79 or it can be J81 depending on options selected. I have a formula in J79, J80, and J81. I need a way to copy the last cell in this column, but it is not the last cell in the whole column of the sheet. Is there a way to define a range I'm looking for the last used cell??

I'm trying to make a quote page where options can make the final price come out on J79 or J81, then the final value cell needs to be copied and pasted to a different cell with in the sheet.

I cant get the first part to work correctly.

Sub FinalAdder()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet


'Selecting the quote sheet
ActiveWorkbook.Sheets("Location Quote").Select

'supposed to find the last used cell after A78, before the next blank cell
Sheets("Location Quote").Range("A78").End(xlDown).Copy

'Pasting previous cell value to the next blank cell above J93
Sheets("Location Quote").Range("J93").End(xlUp).Offset(1).PasteSpecial xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Welcome to the Board!

I have a sheet where the last row can be J79 or it can be J81 depending on options selected.
Why are you using A78 instead of J78?
Code:
[COLOR=#333333]'supposed to find the last used cell after A78, before the next blank cell[/COLOR]
[COLOR=#333333]Sheets("Location Quote").Range("[/COLOR][COLOR=#ff0000]A[/COLOR][COLOR=#333333]78").End(xlDown).Copy[/COLOR]
 
Upvote 0
**Sorry I meant A and not J** The following post is the correct post:

I have a sheet where the last row can be A79 or it can be A81 depending on options selected. I have a formula in A79, A80, and A81. I need a way to copy the last cell in this column, but it is not the last cell in the whole column of the sheet. Is there a way to define a range I'm looking for the last used cell??


I'm trying to make a quote page where options can make the final price come out on A79 or A81, then the final value cell needs to be copied and pasted to a different cell with in the sheet.

I cant get the first part to work correctly.

Sub FinalAdder()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet


'Selecting the quote sheet
ActiveWorkbook.Sheets("Location Quote").Select

'supposed to find the last used cell after A78, before the next blank cell
Sheets("Location Quote").Range("A78").End(xlDown).Copy

'Pasting previous cell value to the next blank cell above J93
Sheets("Location Quote").Range("J93").End(xlUp).Offset(1).PasteSpecial xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
 
Upvote 0
All the cells have if statements like this:

=IF('Sales Configurator'!Q5="Yes","Total Price Before Discount",IF(AND('Sales Configurator'!Q5="No",'Sales Configurator'!Q6>0),"Total Price Before Discount",IF(AND('Sales Configurator'!Q5="No",'Sales Configurator'!Q6=0,'Sales Configurator'!Q7=TRUE),"Total Price Before Discount",'Sales Configurator'!H12&" Total Price")))
 
Upvote 0
If it is really just two cells, why not just check them, something like.
Code:
[COLOR=#333333]If Sheets("Location Quote").Range("A79") <> 0 Then
   InvAmt = [/COLOR][COLOR=#333333]Sheets("Location Quote").Range("A79")
Else
[/COLOR][COLOR=#333333]   InvAmt = [/COLOR][COLOR=#333333]Sheets("Location Quote").Range("A81")
End If[/COLOR]
 
Last edited:
Upvote 0
All the cells have if statements like this:

=IF('Sales Configurator'!Q5="Yes","Total Price Before Discount",IF(AND('Sales Configurator'!Q5="No",'Sales Configurator'!Q6>0),"Total Price Before Discount",IF(AND('Sales Configurator'!Q5="No",'Sales Configurator'!Q6=0,'Sales Configurator'!Q7=TRUE),"Total Price Before Discount",'Sales Configurator'!H12&" Total Price")))

But the last 2 cells have another statement adding an option that if not met the just "" for the cell...making some of the cells blank.

If A79 has total price then you will not have anything but "" for A80 and A81.
If A81 has total price then A80 & A79 will have text displaying discount and price before discount.
I want to copy total price each time and have it transferred to a different cell.
 
Upvote 0
It is just a random variable I am using to "capture" the Invoice Amount (I am capturing it instead of Copying it).

You could then use it to assign to your other range, i.e.
Code:
[COLOR=#333333]Sheets("Location Quote").Range("J93").End(xlUp).Offset(1) = InvAmt
[/COLOR]
Either way should work.
 
Upvote 0
Gotcha!

So I modified the code but may not be following correctly:

Sub Te()
If Sheets("Location Quote").Range("A81") <> 0 Then
InvAmt = Sheets("Location Quote").Range("A81")
Else
InvAmt = Sheets("Location Quote").Range("A79")
End If

End Sub



This should read: If A81 does not equal 0 or blank then set InvAmt = A81
otherwise set InvAmt equal to A79

for some reason every time there is no value in A81 it doesn't take A79 it just uses ""
 
Upvote 0

Forum statistics

Threads
1,224,884
Messages
6,181,555
Members
453,053
Latest member
Kiranm13

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