Intersect the cells value in column with cells value in row? [closed] - vba

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am new doing this and desperate need help
I have a group of value in a column and the same group of value in a row, what I need is a VBA code that select the cells where the column and the row intersect.
Ex.
Col A has values from A2 to A10 and the same values repeat in row 1 from B1:J1
I need a VBA code that select the cell where rowX and ColX intersect.
Thanks

Sub Highlight_Intersections()
'tested
Dim c as Range
For Each c in Range("B2:J10") 'you supply address
If Cells(c.Row,1).Value = Cells(2,c.Column).Value Then
c.Interior.ColorIndex = 6 '(Yellow)
End If
Next c
End Sub

Related

Excel counting rows that are not empty in Vlookup value [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to count the total number of cells that have values for the row that I'll be looking up using their name. I have a different sheet for looking up the value I tried COUNTA and VLOOKUP. Is there any way to combine these two so I'll end up with the correct result?
Please see screenshot.
Thank you!
Use INDEX(,MATCH()):
=COUNTA(INDEX('Sheet1'!C:X,MATCH("Jessel Rayes",'Sheet1'!A:A,0),0))
Here is a vba function that looks up the value you define (first input) in a specified range (second input) and then returns the number of empty cells in the same row right from this cell for a specified amount of columns (third input).
Function TLookupT(Value As Variant, arr As Range, column As Long)
x = 0
For Each Cell In arr
If Cell.Value = Value Then
For i = 1 To column - 1
If Cell.Offset(0, i) = "" Then
x = x + 1
End If
Next i
End If
Next Cell
TLookupT = x
End Function

Cut n cells and insert to below row using excel vba [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am trying cut 4 adjacent cells and insert a new row below and paste it on a new row.
My input is similar to
I have 4 columns Addr,Phone,Count,Amount. Some Rows of my excel sheet contains multiple n numbers of entries. I want to cut multiple of 4 cells and insert a new row below and paste it on.
The output would be similar to
I tried with transform function but unable to produce the expected result.
How can I do this with vba code or any excel functions
Here is the code its exactly work with your requirement
Sub Narasappa()
For i = 2 To 1000
If ThisWorkbook.Worksheets(5).Cells(i, 2) = "" Then
Exit For
End If
For j = 6 To 1000 Step 4
If ThisWorkbook.Worksheets(5).Cells(i, j).Value = "" Then
Exit For
Else
ThisWorkbook.Worksheets(5).Cells(i, j).Resize(, 4).Cut
ThisWorkbook.Worksheets(5).Range("B" & i + 1).Insert xlShiftDown
End If
Next
Next
End Sub

Search Value from A column and Paste Value of B in Column D [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a table below with details in column A and B. I want to search a string in C from A and paste value of Column B in Column D with help of VBA.
Example:-
A B C D
STRAT Strategy s_strat_nhnh Strategy
TRDMK Trademarks bng_trdm_ndnd Trademarks
TRDMK not in bng_trdm_ndnd.
But if I got it right, you want something like
Then Code is:
Sub Test()
CStartRow = 1
CEndRow = 5
AStartRow = 1
AEndRow = 3
For I = CStartRow To CEndRow
For J = AStartRow To AEndRow
If InStr(UCase(Range("C" + CStr(I))), UCase(Range("A" + CStr(J)))) Then
Range("D" + CStr(I)) = Range("B" + CStr(J))
Exit For
End If
Next J
Next I
End Sub
If you do not want to use VBA then you can use this formula.
Formula in d1 cell is:
=IF(ISNUMBER(SEARCH(A1,C1)),B1,"")

How to find the days difference between two dates [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have been working on finding the Days difference between the dates found in Column A and column B. The dates in both columns are not constant thus I would need a code that would allow to read both dates in column A and B and find the Days difference between those two dates until the last row is empty.
Is there any code that I could use to find the Days difference between column A and B with a range of more than 500 rows?
Instead of using vba just enter the formula for the first row on C1 :
=ROUND(a1,0)-ROUND(b1,0)
Then just the formula to the end of exisiting rows.
If you insist using vba code use the simple code below:
Dim LastRow As Long
LastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
Range("c1").Select
ActiveCell.FormulaR1C1 = "=ROUND(RC[-1],0)-ROUND(RC[-2],0)"
Range("c1").AutoFill Destination:=Range("C1:C" & LastRow)
End Sub

VBA help. Column A divide Column B and put answer in Column C for every row [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
In my worksheet (named "Sheet1") I have 388 rows of data. For each row, I want to be able to divide values in Column A by Values in Column B, and put this answer to column C. I would like to keep up this pattern going until the last column. So after the 1st round of calculation, it goes to column D, column D gets divided by column E, and values go into column F.
I want to be able to apply it to every row until the last row and every column until the last column.
I guess I need to use an offset? Any ideas/suggestions on how to do this?
You could try something like this. Untested, but should provide a framework.
condition=True
xrowx=1
xcolx=3
Do While condition=True
with Sheets("Sheet1")
tempA=.Cells(xrowx,xcolx-2).Value
tempB=.Cells(xrowx,xcolx-1).Value
.Cells(xrowx,xcolx)=tempA/tempB
xrowx=xrowx+1
if xrowx>Worksheetfunction.CountA(.Range(.Cells(1,xcolx-1),.Cells(xrowx,xcolx-1))) then
xrowx=1
xcolx=xcolx+3
if .Cells(xrowx,xcolx-1)=0 then
exit do
End if
End if
end with
loop
This is a solution only for C1 thru C388. This macro will place formulas in the appropriate cells:
Sub Bessie()
Range("C1:C388").Formula = "=A1/B1"
End Sub
each formula will be adjusted to match the row.
Update the macro for any other columns you wish to fill.