Cell Referencing - Recognizing Data from Row

carrieebacon

New Member
Joined
Jan 15, 2024
Messages
48
Office Version
  1. 365
Platform
  1. Windows
Okay A) I would like to apologize for constantly posting on here, but I am learning. B) I have one sheet in a workbook that contains asbuilt data (ASBUILT), and one sheet that will be used to format the text that I will place into Trimble Business Center (TBC TEXT). I would like to pull (or reference) from column J in ASBUILT to place into either column D, F, I, or L. The thing is, it needs to align with the correct ID number in column B in ASBUILT. If there is a better way to do what I am trying to do, feel free to tell me. I have been working on putting this together for a while and I think I have lost my sanity.

Here is what I am working with.

This is the ASBUILT sheet
ASBUILT SNIP.PNG


And this is the TBC TEXT sheet
TBC TEXT SNIP.PNG
 
Was that a one-time mistake or can it happen again? That kind of mistake will cause problems for the code.
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
It won't happen again. While I am working on this, my boss is creating a feature code library for the field techs. With the FXL in their data collectors, they wont be able to just type whatever they want. They'll have to choose from a drop down list.
 
Upvote 0
Try:
VBA Code:
Sub FillElevation()
    Application.ScreenUpdating = False
    Dim v1 As Variant, v2 As Variant, i As Long, ii As Long, srcWS As Worksheet, desWS As Worksheet
    Dim Val1 As String, Val2 As String, Val3 As String
    Set srcWS = Sheets("ASBUILT")
    Set desWS = Sheets("TBC TEXT")
    v1 = desWS.Range("B6", desWS.Range("B" & Rows.Count).End(xlUp)).Resize(, 12).Value
    v2 = srcWS.Range("H6", srcWS.Range("H" & Rows.Count).End(xlUp)).Resize(, 3).Value
    For i = LBound(v1) To UBound(v1)
        If WorksheetFunction.CountIf(srcWS.Range("H6", srcWS.Range("H" & Rows.Count).End(xlUp)), v1(i, 1)) > 0 Then
            Val1 = v1(i, 1) & "|" & v1(i, 6)
            Val2 = v1(i, 1) & "|" & v1(i, 9)
            Val3 = v1(i, 1) & "|" & v1(i, 12)
            For ii = LBound(v2) To UBound(v2)
                If v2(ii, 1) & "|" & v2(ii, 2) = Val1 Then
                    desWS.Range("F" & i + 5) = v2(ii, 3)
                ElseIf v2(ii, 1) & "|" & v2(ii, 2) = Val2 Then
                    desWS.Range("I" & i + 5) = v2(ii, 3)
                ElseIf v2(ii, 1) & "|" & v2(ii, 2) = Val3 Then
                    desWS.Range("L" & i + 5) = v2(ii, 3)
                End If
            Next ii
        End If
    Next i
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
I tested the macro on the file you uploaded and it worked properly. Are you using the macro on a different file?
 
Upvote 0
I am using it on the original file. I made a copy of it which is what I uploaded to box.com
 
Upvote 0
Upvote 0
So the data will populate in the respective row in TBC TEXT only if all of the required asbuilt data is there? Or am I blind. Either way, it's fine I just want to have my ducks in a row.
 
Upvote 0
The macro searches to check if each ID in the TBC TEXT sheet exists in the ASBUILT sheet. If it exists, it will populate in the respective row in TBC TEXT if the data exists in the ASBUILT sheet. Otherwise it will return blank values.
 
Upvote 0

Forum statistics

Threads
1,215,843
Messages
6,127,240
Members
449,372
Latest member
charlottedv

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