Hi
I want to find exact cell that belongs to each utmx in sheet and copy it to entire column in utmx name sheet if the cell is not empty and replace it .(column l)
b1-------------->b2-------------->c
thanks
Hi
I want to find exact cell that belongs to each utmx in sheet and copy it to entire column in utmx name sheet if the cell is not empty and replace it .(column l)
b1-------------->b2-------------->c
thanks
Last edited by fakhteh; 04-03-2021 at 07:31 AM.
Assuming your main sheet is called "Sheet1", try this code
![]()
Sub chmgcell() 'Change Sheet1 to name of your main sheet Dim cel, rng As Range Dim lr, lrn As Long lr = Sheets("Sheet1").Cells(Rows.Count, 3).End(xlUp).Row Set rng = Sheets("Sheet1").Range("C2:C" & lr) For Each cel In rng If Not IsEmpty(cel.Offset(0, 7).Value) Then lrn = Sheets(Trim(cel)).Cells(Rows.Count, 7).End(xlUp).Row Sheets(Trim(cel)).Range("L2:L" & lrn).Value = cel.Offset(0, 7).Value End If Next cel End Sub
Last edited by maniacb; 04-03-2021 at 08:49 AM. Reason: added code to account for empty values
hi again
first of all I appreciate your help
something is wrong so I attach an excel file to clarify it
for example :you can see sheet2 and 238458 in excel file
so I want to change and correct 238458 --to-----> 238458- with j25 in sheet2
((please do this correct just in 238458 and do not open and create another sheet like 238458-))
as I mentioned before I have many sheets for changing with finding dependent cell from sheet2
I run your code and the error is shown in image that I attached
thank you
Give this a try
![]()
Sub chmgcell() 'Change Sheet2 to name of your main sheet Dim cel, rng As Range Dim lr, lrn As Long lr = Sheets("Sheet2").Cells(Rows.Count, 3).End(xlUp).Row Set rng = Sheets("Sheet2").Range("C2:C" & lr) For Each cel In rng If Not IsEmpty(cel.Offset(0, 7).Value) Then On Error Resume Next lrn = Sheets(Trim(cel)).Cells(Rows.Count, 7).End(xlUp).Row If lrn <> 0 Then Sheets(Trim(cel)).Range("L2:L" & lrn).Value = cel.Offset(0, 7).Value lrn = 0 End If On Error GoTo 0 End If Next cel End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks