I need to show at sheet1 in Cell "A1" last number on a last row from sheet2 Column A, but it does not appear as expected...

reinsermat

New Member
Joined
May 5, 2020
Messages
20
Office Version
  1. 365
Platform
  1. Windows
Hello!


Sorry for bad english, I really hope, you do understand the question.

I have problem. My Paste works well, but I lost my "Next enter ID"
I need to show at sheet "P" (Sheet1) in Cell "A1" last number on a last row from sheet "p_koond" (Sheet2) Column A, but it does not appear as expected...
Anybody can offer a solution?
i'am very new on this, so every move takes a ton of time.

Thank you for any help!


Private Sub vaart_sis_GI_Click()

P_vaart_G.Hide
Dim SourceWS As Worksheet, DestWS As Worksheet
Dim NxtRw As Long

Set SourceWS = Sheets("P")
Set DestWS = Sheets("p_koond")
Application.ScreenUpdating = 0
NxtRw = DestWS.Cells.Find("*", , , , xlByRows, xlPrevious, , , False).Row + 1
SourceWS.Range("B3:N3").Copy
DestWS.Range("B" & NxtRw).PasteSpecial xlPasteValues
Application.CutCopyMode = False


Range("D3:N6").Select
Range("N6").Activate
Selection.ClearContents


With Sheets("p_koond") '<--| reference "source" sheet- HERE START'S THE PROBLEM?
With Range(.Cells(.Rows.Count, "A").End(xlUp), _
.Cells(.Cells(.Rows.Count, "A").End(xlUp).Row, .Columns.Count).End(xlToLeft)) '<--| reference is range from its column A last not empty cell to this latter cell row last not empty cell
Worksheets("p").Range("A1").Resize(, .Columns.Count).Value = .Value '<--| paste values to "target" sheet starting from its cell A1
End With
End With
End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Do you want to copy the entire row across, or just one cell?
 
Upvote 0
Do you want to copy the entire row across, or just one cell?
Thank you for quick reply!

I would like to have only the last active cell in column A (picture included)
 

Attachments

  • problem3.png
    problem3.png
    25.3 KB · Views: 7
Upvote 0
In that case replace this
VBA Code:
With Sheets("p_koond") '<--| reference "source" sheet- HERE START'S THE PROBLEM?
With Range(.Cells(.Rows.Count, "A").End(xlUp), _
.Cells(.Cells(.Rows.Count, "A").End(xlUp).Row, .Columns.Count).End(xlToLeft)) '<--| reference is range from its column A last not empty cell to this latter cell row last not empty cell
Worksheets("p").Range("A1").Resize(, .Columns.Count).Value = .Value '<--| paste values to "target" sheet starting from its cell A1
End With
End With
with
VBA Code:
      Worksheets("p").Range("A1").Value = Sheets("p_koond").Range("A" & Rows.Count).End(xlUp).Value
 
Upvote 0
Seems, that nothing happens. Just empty Cell.
Maybe this problem is caused by using on sheet also this code:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo errh
Dim t As Long
If Not Intersect(Target, Range("B:B")) Is Nothing Then
Application.EnableEvents = False
Range("A:A").ClearContents
t = 0
For Each r In Range("B:B").SpecialCells(xlCellTypeConstants)
If r.Row <> 1 Then
t = t + 1
r.Offset(, -1).Value = t
End If
Next
errh:
Application.EnableEvents = True
End If
End Sub


But my code looks now like this. Not working...

VBA Code:
Private Sub vaart_sis_GI_Click()
P_vaart_G.Hide
   Dim SourceWS As Worksheet, DestWS As Worksheet
   Dim NxtRw As Long
  
   Set SourceWS = Sheets("P")
   Set DestWS = Sheets("p_koond")
   Application.ScreenUpdating = 0
   NxtRw = DestWS.Cells.Find("*", , , , xlByRows, xlPrevious, , , False).Row + 1
   SourceWS.Range("B3:N3").Copy
   DestWS.Range("B" & NxtRw).PasteSpecial xlPasteValues
   Application.CutCopyMode = False

  
    Set SourceWS = Sheets("P")
   Set DestWS = Sheets("p_koond")
   Application.ScreenUpdating = 0
   NxtRw = DestWS.Cells.Find("*", , , , xlByRows, xlPrevious, , , False).Row + 1
   SourceWS.Range("B7:F7").Copy
   DestWS.Range("B" & NxtRw).PasteSpecial xlPasteValues
   Application.CutCopyMode = False

       Range("D3:N6").Select
    Range("N6").Activate
    Selection.ClearContents
   
    Worksheets("P").Range("A1").Value = Sheets("p_koond").Range("A" & Rows.Count).End(xlUp).Value

End Sub
 
Upvote 0
Do you have formulae in col A of the p_koond sheet?
 
Upvote 0
Ok, in that case use
VBA Code:
      Worksheets("p").Range("A1").Value = Sheets("p_koond").Range("A:A").Find("*", , , , xlByRows, xlPrevious, , , False).Value
 
Upvote 0
Thank you!
For me you are a superhero.
I feel so stupid...
I'am not a computer person, but I'am good at my work (environment for 25 years) and there is no computer person who can understand my needs about excel (or to combine mysql, & autocad & html etc...) so I have to figure it out step by step on my own.

6 months now... pff, but I'am very close now :)
So, you are really my hero!

Rein Sermat
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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