Finding last used cell in a Range and ADD form values into the Worksheet

ragav

New Member
Joined
Feb 13, 2018
Messages
1
Hello guys,

Need some help here. I have a form and I need my code to update the form values into a specific range (M55:Q65) in my worksheet.

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"]Rno[/TD]
[TD="align: center"]M[/TD]
[TD="align: center"]N[/TD]
[TD="align: center"]O[/TD]
[TD="align: center"]P[/TD]
[/TR]
[TR]
[TD="align: center"]52[/TD]
[TD="align: center"]End of Booking Data[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]53[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]54[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]55[/TD]
[TD="align: center"]eDM Name[/TD]
[TD="align: center"]Tot sends[/TD]
[TD="align: center"]Uniq OR[/TD]
[TD="align: center"]Uniq CTR[/TD]
[/TR]
[TR]
[TD="align: center"]56[/TD]
[TD="align: center"]Need the data to updated 4rm this line[/TD]
[TD="align: center"]
[/TD]
[TD="align: center"]
[/TD]
[TD="align: center"]
[/TD]
[/TR]
[TR]
[TD="align: center"]57[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]58[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]59[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]60[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]61[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]62[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]63[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]64[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]65[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]66[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]67[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]68[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]69[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]70[/TD]
[TD="align: center"]End of eDM Data[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]71[/TD]
[TD="align: center"]But Data is getting updated here[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]


view


view


Code:
Private Sub add_edm_data_Click()

Dim sht, cmp_dash As Worksheet
Dim find_row_eDM, find_col_camp, edm_upd_row_no As Integer

Set sht = ThisWorkbook.Worksheets("Campaign Results Data")
Set cmp_dash = ThisWorkbook.Worksheets("Campaign Dashboard")

find_col_camp = sht.Cells.Find(What:=camp_results.camp_name.Caption, After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlNext).Column
find_row_eDM = sht.Cells.Find(What:="eDM Name", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlNext).Row

sht.Activate
Set eDM_range = sht.Range(Cells(find_row_eDM, find_col_camp), Cells(find_row_eDM + 10, find_col_camp + 4))
edm_upd_row_no = eDM_range.End(xlDown).Row


'Update eDM Values

sht.Cells(edm_upd_row_no + 1, find_col_camp).Value = edm_name.Value
sht.Cells(edm_upd_row_no + 1, find_col_camp + 1).Value = tot_sends.Value
sht.Cells(edm_upd_row_no + 1, find_col_camp + 2).Value = Format(uq_OR.Value, "%")
sht.Cells(edm_upd_row_no + 1, find_col_camp + 3).Value = Format(uq_CTR.Value, "%")

cmp_dash.Activate

End Sub

But the data gets updated from row 71. I believe I am doing something wrong. Could someone plz guide me?

Thanks
Ragav.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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