How do I concatenate different column value to single cell? [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
.
Hello guys,I need your inputs on the topic here.
I intend to combine or concatenate different value in different columns so its shown in a single cell.
Illustration is the following:
1:
Is it possible to do this without macro?

use
=CONCATENATE("The name of the painter: ",A3,CHAR(10), "The Hobby: ", B3, CHAR(10), "Tool used: ", C3,CHAR(10),"Remuneration: ", D3)

To answer your second question on how to do it with code:
Sub PopulateResultsToCell()
Dim X As Long, MyArr As Variant, PrefixArr As Variant
PrefixArr = Array("The name of the painter: ", "The Hobby: ", "Tool used: ", "Remuneration: ")
MyArr = Application.Transpose(Application.Transpose(Range("A3:D3"))) '<-- Change this for the range to read
For X = LBound(MyArr) To UBound(MyArr)
MyArr(X) = PrefixArr(X - 1) & Trim(MyArr(X)) 'Note: Option base is zero but transposing creates a base 1 array hence the X minus 1
Next
Range("F3").Formula = Join(MyArr, vbLf) '<-- Change this for where to populate the result to
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

Excel VBA find part number from indented BOM [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
We have a software (Solidworks) from wich we extract a Bill of Materials in an Excel spreadsheet.
It returns the following data:
I would like to create a VBA macro that populates column C (parent) with the parent part number. For exemple cell C6 would display : 101-07798-111.
I managed to do it with an Excel formula directly in the worksheet, however I would like to do it with a VBA macro.
The excel formula requires 2 columns.
"Column D" in wich I do a concatenate of a letter and the data of "column A".
"Column E" wich does an Index(match) search of "column A" data to return the value of "Column B".
Column D formula : =CONCATENATE("A";A3) *without this step the main formula have errors
Column E formula : =INDEX($B$1:$B$250;MATCH((IFERROR(LEFT(D3; FIND("$"; SUBSTITUTE(D3; "."; "$"; LEN(D3)-LEN(SUBSTITUTE(D3; "."; ""))))-1);"-"));$D$1:$D$250;0))
I found ways to have a VBA script populate the rows with the formula; however since the formula contain a lot of " it causes error in the script.
What could be the best way to use the data in "column a" to get the value of "column B" in a vba script?
Thank you
I figured what the heck I want to figure this out so this is how I would do it.
Dim splitVariable As Variant
Dim level As Integer
Dim stringToFind As String
For Each cell In Range("A1:A" & [A1].End(xlDown).Row)
splitVariable = Split(cell.Value, ".") 'split the cell on the period to find the level
level = UBound(splitVariable) + 1 'add one because array is 0 indexed
If level > 1 Then 'don't do anything for the first level
stringToFind = Left(cell, level - 3 + level) 'get the level of the parent
For Each parentCell In Range("A1:A" & [A1].End(xlDown).Row) 'loop through rang again to find level
If parentCell.Value = stringToFind Then 'when the parent is found then paste it to column C
cell.Offset(0, 2) = parentCell.Offset(0, 1)
Exit For
End If
Next
End If
Next
don't know if that helps at all.

Excel data entry with date matching plus move to another sheet after table run out [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 new to VBA and would like to learn by creating expense database, How do I transferring and making monthly database?
If dashboard date is matching to Aug17 column A, move data from dashboard to Aug17 respective row. If possible, I would like it to search dashboard date to all worksheet and move data to respective row if matching found. Thanks in advance.
DashBoard
Aug17
Based on your response to my questions in the comments here's code that does what you asked. Notice that the final msgbox will never be encountered if the date is found. Hopefully you will be able to adjust this code to suit your needs once you understand it.
Sub test()
Dim r As Range, dashSh As Worksheet, dashR As Range, sh As Worksheet
Dim mo As String, yr As String
Set dashSh = Worksheets("Dashboard")
Set dashR = dashSh.Range("A5:J5")
mo = Application.WorksheetFunction.Text(dashR.Columns(1), "mmm")
yr = Application.WorksheetFunction.Text(dashR.Columns(1), "yy")
Set sh = Worksheets(mo & yr)
sh.Activate
Set r = sh.Range("A5")
While r <> ""
If r = dashR.Columns(1) Then
r.Select
dashR.Copy
sh.Paste
End
End If
Set r = r.Offset(1, 0)
Wend
MsgBox ("date not found")
End Sub

How to average every 3rd row in excel using 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 have column I with "item score". I would like to average every third row and return the value in Column A, which I have labeled "Overall Survey Score".
So the average of I2:I4 would be displayed in A2. The average of I5:I7 would be displayes in A5 and so on until the last row of data available.
I would like stay away from a formula in a cell and do this using VBA. Any help would be greatly appreciated.
Sub getavgs()
Dim i As Integer
For i = 1 To 27 Step 3
ActiveWorkbook.Worksheets("Sheet1").Range("A" & i).Value = _
(ActiveWorkbook.Worksheets("Sheet1").Range("L" & i).Value + _
ActiveWorkbook.Worksheets("Sheet1").Range("L" & i + 1).Value + _
ActiveWorkbook.Worksheets("Sheet1").Range("L" & i + 2).Value) / 3
Next i
End Sub
You can use a formula, like so. In I2 onwards
=IF(OR(ROW()-2=0,MOD(ROW()-2,3)=0),AVERAGE(OFFSET(I2,0,0,3,1)),"")

Delete spaces in cell - VBA [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 8 years ago.
Improve this question
I have the following string in excel:
" 163,40 3,10 1,86 163,30 163,40 167,00 163,30 435862329"
And I have no problem to split up this column into 8 individual columns - one for each block of data. But I saw that the first column - here 163.40 is truncated so it becomes 163 - that is from a float to an integer. I realized later thats because the numbers is preceeded by four spaces - " 163.40".
So my question is how to delete these four spaces - and ONLY these four first spaces.
That would solve my problem.
Any ideas?
Use Mid function like used below for your problem.
Mid(text, 5, Len(text))
Assuming that your source string is in cell A1 and you need the 8 columns data in row 2 ; please refer to below code :
Function SplitMyData()
Dim var As Variant
var = Split(Trim(Range("A1").Value), " ", , vbTextCompare)
For i = 0 To UBound(var)
Cells(2, i + 1).Value = var(i) 'Pasting vals in row 2
Next
End Function
You can change the source and destination cell references as per your requirements. :)