I am having trouble combining RangeToPaste which is Range("M3:R") and x which is Range("A1").Value.
Sub AutoFillProjection()
Sheets("Projection").Select
x = Range("A1").Value
y = Range("A2").Value
Dim RangeToCopy As Range
Dim RangeToPaste As Range
Set RangeToCopy = Range("M2:R2")
Set RangeToPaste = Range("M3:R")
RangeToCopy.Select
Selection.Copy
RangeToPaste & x.Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
RangeToPaste & x.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Related
I have a workbook with a list of pallet names. I also have userform and 7 comboboxes with the names in it. Comboboxes are populated from a range like this:
Me.ComboBox1.List = Worksheets("palety").Range("E7:E1341").Value
Right now I have to type the exact name of the pallet to be able to search for it. I want to just type a part of it and have it appear in the dropdown list. Tried this code:
Private Sub cboProgrammeName_Change()
Dim ws As Worksheet
Dim x, dict
Dim i As Long
Dim str As String
Set ws = Sheets("XXX")
x = ws.Range("ProgrammeNameList").Value
Set dict = CreateObject("Scripting.Dictionary")
str = Me.cboProgrammeName.Value
If str <> "" Then
For i = 1 To UBound(x, 1)
If InStr(LCase(x(i, 1)), LCase(str)) > 0 Then
dict.Item(x(i, 1)) = ""
End If
Next i
Me.cboProgrammeName.List = dict.keys
Else
Me.cboProgrammeName.List = x
End If
Me.cboProgrammeName.DropDown
End Sub
The code itself worked, but my insert and copy macro went wild, and stopped working properly. Inserted it to the wrong row, and thus copied the wrong pallet. I added the code to ComboBox1_change
For example:
we have a pallet with name TestPallet 123, PalletTest 123, 123 Test. When I type in 123 i would like to have appear every pallet that contain 123 in it.
This is my code, it searches the chosen pallet from ComboBoxes, then inserts the number from TextBoxes. After that autofilters the field and copies the visible cells into another sheet. When I tried the code above the search and insert part did not worked.
Public Sub Import_Click()
Dim palety As Worksheet
Dim skracovanie As Worksheet
Dim harmonogram As Worksheet
Dim i As Long
Set palety = ThisWorkbook.Worksheets("palety")
Set skracovanie = ThisWorkbook.Worksheets("skracovanie")
Set harmonogram = ThisWorkbook.Worksheets("harmonogram")
palety.Range("M7:M1331").ClearContents
Dim idx As Long
Dim idxList As Long
Dim lngRow As Long
For idx = 1 To 7
idxList = Me.Controls("ComboBox" & idx).ListIndex
If idxList <> -1 Then
lngRow = idxList + 7
Worksheets("palety").Range("M" & lngRow).Value = Me.Controls("TextBox" & idx).Value
End If
Next idx
skracovanie.Activate
skracovanie.Range("A3:M100").ClearContents
skracovanie.Range("P3:Q100").ClearContents
skracovanie.Range("X:X").ClearContents
Sheets("palety").Select
ActiveSheet.Range("M:M").AutoFilter Field:=13, Criteria1:=">=1"
'név
palety.Range("E1347:E4000").SpecialCells(xlCellTypeVisible).Copy
skracovanie.Cells(3, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'kód vstupného reziva
palety.Range("V1347:V4000").SpecialCells(xlCellTypeVisible).Copy
skracovanie.Cells(3, 2).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'kód palety
palety.Range("C1347:C4000").SpecialCells(xlCellTypeVisible).Copy
skracovanie.Cells(3, 3).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'harmonogram fulre
Worksheets("harmonogram").Range("A5:A62").ClearContents
palety.Range("C7:C1341").SpecialCells(xlCellTypeVisible).Copy
harmonogram.Cells(5, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'kód prírezov
palety.Range("G1347:G4000").SpecialCells(xlCellTypeVisible).Copy
skracovanie.Cells(3, 4).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'méretek
palety.Range("H1347:J4000").SpecialCells(xlCellTypeVisible).Copy
skracovanie.Cells(3, 5).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'darabszám
palety.Range("M1347:M4000").SpecialCells(xlCellTypeVisible).Copy
skracovanie.Cells(3, 8).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'poznámka
palety.Range("BI1347:BI4000").SpecialCells(xlCellTypeVisible).Copy
skracovanie.Cells(3, 9).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'objem celkom
palety.Range("N1347:N4000").SpecialCells(xlCellTypeVisible).Copy
skracovanie.Cells(3, 12).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'výťaž
palety.Range("X1347:X4000").SpecialCells(xlCellTypeVisible).Copy
skracovanie.Cells(3, 13).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'príprava
palety.Range("P1347:P4000").SpecialCells(xlCellTypeVisible).Copy
skracovanie.Cells(3, 16).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'spotreba času na 100 ks
palety.Range("Q1347:Q4000").SpecialCells(xlCellTypeVisible).Copy
skracovanie.Cells(3, 17).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'prírez V szog
palety.Range("F1347:F4000").SpecialCells(xlCellTypeVisible).Copy
skracovanie.Cells(3, 24).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
my code that was solved; code copied from here
I have a main sheet, its a dashboard style sheet pulling in information from linked sheets(its used to spot check). All the results for the sheet is driven by one cell(an ID), I have a list of IDs that I want to flow through the cell and then copy the one line of results and append it to some other sheet. I recorded the function to try to explain what im doing.
Sheets("Data Input").Select
Range("L3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=List!R[1]C[-11]"
Rows("32:32").Select
Selection.Copy
Sheets("results").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
I then did it multiple times to show how the whole process would look:
Sheets("Data Input").Select
Range("L3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=List!R[2]C[-11]"
Rows("32:32").Select
Selection.Copy
Sheets("results").Select
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Data Input").Select
Range("L3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=List!R[3]C[-11]"
Rows("32:32").Select
Selection.Copy
Sheets("results").Select
Range("A5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Data Input").Select
Range("L3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=List!R[4]C[-11]"
Rows("32:32").Select
Selection.Copy
Sheets("results").Select
Range("A6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
So overall theres three sheets. Data input where the results and functions live, List where contains a list of IDs and Results where I just need to append the one row from Data Input(row32)
You can do something like this:
Dim wsList As Worksheet, wsData As Worksheet, wsResult As Worksheet
Dim c As Range, rwDest As Range
Set wsList = ThisWorkbook.Worksheets("List")
Set wsData = ThisWorkbook.Worksheets("Data Input")
Set wsResult = ThisWorkbook.Worksheets("Result")
Set rwDest = wsResult.Rows(3) 'first destination row
For Each c In wsList.Range("A2:A100").Cells 'for example
If c.Value <> "" Then
wsData.Range("L3").Value = c.Value
wsData.Calculate
rwDest.Value = wsData.Rows(32).Value 'copy row values
Set rwDest = rwDest.Offset(1, 0) 'next destination row
End If
Next c
I am trying to record a macro that copies values from 4 cells then pastes them on another sheet that serves as a sort of log. I cannot get the values to paste in a new row though despite using the "Relative References" button when recording the macro. Is there something I can add to the code below to make the values paste in the next available row?
'''
Sub Again()
'
' Again Macro
'
'
Range("B5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Results").Select
ActiveCell.Offset(0, -3).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Test").Select
Range("C5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Results").Select
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Test").Select
Range("D5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Results").Select
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Test").Select
Range("E5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Results").Select
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
'''
Sub add_value()
Dim wbA As Workbook
Dim wsA As Worksheet
Set wbA = ActiveWorkbook
Set wsA = wbA.Worksheets("Sheet1")
Dim nrow As Long
nrow = 6
Do Until wsA.Range("B" & nrow).Value = ""
wsA.Range("B" & nrow).Value = wsA.Range("B3").Value
wsA.Range("C" & nrow).Value = wsA.Range("C3").Value
Exit Sub
nrow = nrow + 1
Loop
End Sub
This is actually working, now i just have to figure out how to offset it
I'm getting a compile error when I try to run this code:
(Only a section of it is shown here because only one bit is highlighted in the debugger)
The bolded bit is the part which is giving me problems.
The references I have active are:
Visual Basic for Applications
Microsoft Excel 16.0 Object Library
Microsoft ActiveX Data Objects 6.1 Library
OLE Automation
Microsoft Office 16.0 Object Library
We're running in Word and Excel 2016.
Any help would be greatly appreciated.
'This will delete any rows that have findings that took place prior to the date that was previously entered.
For CellNum = TotalRowNum To 1 Step -1
If Cells(CellNum, 10) < backtolong Then Rows(CellNum).Delete
Next
CurrentRowNum = Cells(Rows.Count, 2).End(xlUp).Row
'This sorts the findings remaining based on alphabetical order, to make the copy over to word easier as A is first... etc.
Range("A1:J" & CurrentRowNum).Sort key1:=Range("I1:I" & CurrentRowNum), order1:=xlAscending, Header:=xlNo
Dim lastrow As Long
lastrow = ThisWorkbook.Sheets("Pre-Transfer Table").Range("A1", ThisWorkbook.Sheets("Pre-Transfer Table").Range("A1").End(xlDown)).Rows.Count
'Designates the file that the data will be transferred to.
Dim stWordDocument As String
stWordDocument = InputBox("Please enter the name of the word file you have created for this report (Include '.doc').")
**Dim wdApp As Word.Application**
Dim wdDoc As Word.Document
Dim wdCell As Word.Cell
Dim i As Long
Dim j As Long
Dim wbBook As Workbook
Dim wsSheet As Worksheet
Dim vaData As Variant
Set wbBook = ThisWorkbook
Set wsSheet = wbBook.Worksheets("Pre-Transfer Table")
'Creates a 2D array populated by all of the finding critera
ReDim vaData(1 To lastrow, 1 To 8)
With wsSheet
vaData = .Range("A1:H" & lastrow)
End With
Set wdApp = New Word.Application
'Opens the word document by accessing the same folder the workbook is stored in
Set wdDoc = wdApp.Documents.Open(wbBook.Path & "\" & stWordDocument)
'Populates the tables with the corresponding criteria
k = 4
For i = 1 To lastrow
j = 0
For Each wdCell In wdDoc.Tables(k).Columns(2).Cells
j = j + 1
wdCell.Range.Text = vaData(i, j)
Next wdCell
k = k + 1
Next i
'Deletes the sheet used for sorting, as the code cannot run again unless this sheet is removed or the name of it is changed.
ThisWorkbook.Sheets("Pre-Transfer Table").Delete
With wdDoc
.Save
.Close
End With
wdApp.Quit
'Frees up memory by clearing these variables.
Set wdDoc = Nothing
Set wdApp = Nothing
MsgBox "Your report has been generated.", vbInformation
End Sub
This section is giving me the error:
Sheets("Other Findings").Select
**Range("Table2[ASSIGNED" & Chr(10) & "TO]").Select**
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("E" & FindingRowNum + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks
:=False, Transpose:=False
In the code section
'Creates the sheet where the resorting of data is done. All of the relevant columns are copied over to this table.
Sheets.Add
ActiveSheet.Name = "Pre-Transfer Table"
Sheets("Risk Ranked Findings").Select
Range("Table1[DETAILS]").Select
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Risk Ranked Findings").Select
Range("Table1[LOCATION]").Select
Application.CutCopyMode = False
Selection.Copy
Application.CutCopyMode = False
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Risk Ranked Findings").Select
Application.CutCopyMode = False
Range("Table1[TYPE]").Select
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("C1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Risk Ranked Findings").Select
Range("Table1[RECOMMENDED" & Chr(10) & "ACTION]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("D1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Risk Ranked Findings").Select
Range("Table1[DUE DATE]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("E1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = True
Selection.NumberFormat = "m/d/yyyy"
Sheets("Risk Ranked Findings").Select
Range("Table1[ASSIGNED" & Chr(10) & "TO]").Select
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("F1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Risk Ranked Findings").Select
Range("Table1[RISK]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("I1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Risk Ranked Findings").Select
Range("Table1[FINDING" & Chr(10) & "DATE]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("J1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Risk Ranked Findings").Select
Range("S2").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("M1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
FindingRowNum = Range("M1")
'This area is where the "Other Findings" are sorted and transferred. There is probably some redundancy here so if anything is to be cleaned up it is
'most likely this.
Dim OtherRowNum As Long
Dim TotalRowNum As Long
Dim CurrentRowNum As Long
Sheets("Other Findings").Select
Range("O2").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("M2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
OtherRowNum = Range("M2")
TotalRowNum = OtherRowNum + FindingRowNum
Sheets("Other Findings").Select
Range("Table2[DETAILS]").Select
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("A" & FindingRowNum + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Other Findings").Select
Range("Table2[LOCATION]").Select
Application.CutCopyMode = False
Selection.Copy
Application.CutCopyMode = False
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("B" & FindingRowNum + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Other Findings").Select
Application.CutCopyMode = False
Range("Table2[RECOMMENDED" & Chr(10) & "Action]").Select
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("C" & FindingRowNum + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Other Findings").Select
Range("Table2[DUE DATE]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("D" & FindingRowNum + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = True
Selection.NumberFormat = "m/d/yyyy"
Sheets("Other Findings").Select
Range("Table2[ASSIGNED" & Chr(10) & "TO]").Select
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("E" & FindingRowNum + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Other Findings").Select
Range("Table2[TYPE]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("I" & FindingRowNum + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Other Findings").Select
Range("Table2[FINDING" & Chr(10) & "DATE]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Pre-Transfer Table").Select
Range("J" & FindingRowNum + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sub Load()
'
' Load Evaluation Macro
'
'
Dim zelda As Integer
zelda = Lookup()
Sheets("RawData").Select
Range("A" & zelda).Select (highlighted row in yellow)
Selection.Copy
Sheets("Evaluation Form").Select
Range("D1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("RawData").Select
Range("C" & zelda & " :G" & zelda).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Evaluation Form").Select
Range("D3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("RawData").Select
Range("J" & zelda & " :U" & zelda).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Evaluation Form").Select
Range("C10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Sheets("RawData").Select
Range("V" & zelda & " :X" & zelda).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Evaluation Form").Select
Range("C26").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Sheets("RawData").Select
Range("X" & zelda & " :Y" & zelda).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Evaluation Form").Select
Range("C33").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
'--------------------Load Comments------------------------------------------
Sheets("RawData").Select
Range("AA" & zelda & " :AL" & zelda).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Evaluation Form").Select
Range("E9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Sheets("RawData").Select
Range("AM" & zelda & " :AO" & zelda).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Evaluation Form").Select
Range("E19").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Sheets("RawData").Select
Range("AP" & zelda & " :AQ" & zelda).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Evaluation Form").Select
Range("E24").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
'----------------------------------------------------------------------------
Range("E1").Select
End Sub
Function LookUp() As Integer
Dim NameAgent As String
Dim EvalID As Integer
Dim nrow As Long
Dim ncol As Long
Dim i As Long
' Look Up Values ---------------------
Sheets("Evaluation Form").Select
NameAgent = Range("D1").Value
EvalID = Range("D6").Value
'------------------------------------
Sheets("RawData").Select
nrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To nrow
If NameAgent = Cells(i, 1).Value Then
If Cells(i, 4).Value = EvalID Then
LookUp = i
End If
Else
End If
Next i
End Function
I have used this same macro in numerous workbooks and specifically this one is not running correctly.
Any help will be greatly appreciated.