Excel extracting multiple matching rows

Excel extracting multiple matching rows

I have a matrix of data which has the records of diferent products ( by serial number) and a category (name of the brand) which has several products.
The data set consists of multiple columns for each product and I want to compare the different categories with a box-Whisher plot some of the settings.

enter image description here

For example, I want to compare results from Data1 for the two diferent motor brands.

My question is how can I dinamically select the range of each “brand"?

I would search for the name of the motor I would like to plot in the leftmost column and retrive the rows with the column content I wish to plot. Though, I can not figure out how I could do this in excel.

Thanks!

EDIT:

The idea is to automatically update each series value of the box plot, where each series name is the brand of the motor. I have 10 different brands of motors, where they could have different number of serial numbers. Therefore, I am looking for a formula/VBA that could for each motor type " see how many serial numbers exist(rows) of that motor and select the values of one data type (e.g. Data1)to the series value of the box plot.
I do not know if I explained my problem clearly..

I would recommend being more specific with your desired output. There are many ways of achieving what you want it to do, but some are more efficient than others, depending on how you wish to manipulate with the data afterwards. Ideally create a mockup of an expected output of the data you provided in your picture
– Rawrplus
Jul 3 at 9:16

The idea is to automatically update each series value of the box plot, where each series name is the brand of the motor. I have 10 different brands of motors, where they could have different number of serial numbers. Therefore, I am looking for a formula/VBA that could for each motor type " see how many serial numbers exist(rows) of that motor and select the values of one data type (e.g. Data1)to the series value of the box plot. I do not know if I explained my problem clearly..
– Francisco Costa
Jul 3 at 10:57

1 Answer
1

The range of Rolls Royce in columns A:G will be,

=index(a:a, match("Rolls Royce", a:a, 0)):index(g:g, aggregate(14, 6, row($2:$9999)/(a$2:a$9999="Rolls Royce"), 1))

This range can be proved with the sum of column D (data1).

=sum(index(d:d, match("Rolls Royce", a:a, 0)):index(d:d, aggregate(14, 6, row($2:$9999)/(a$2:a$9999="Rolls Royce"), 1)))

By clicking “Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

I need to filter data in PowerPoint and load data from excel using VBA exactly like the attached GIF

I need to filter data in PowerPoint and load data from excel using VBA exactly like the attached GIF

This is the Gif I needed to create with different set.

Thanks

Sales Figures

and … what’s the question? Where exactly in your efforts did you get stuck?
– MikeD
Jul 3 at 10:23

Thanks for your response! The first issue is, this code is not working on excel 2010 The second issue, If I share PPT & Xlsx file with my workmates, they can’t use it before saving both files on their devices and change the file location path in code
– Ahmed Baghdadi
Jul 5 at 9:13

By clicking “Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How to compare dates in Access VBA?

How to compare dates in Access VBA?

I have an Access database with two date/hour fields “record_init_date" and “record_end_date".

I have a query to retrieve the records with record_init_date >= init_date and record_end_date <= end_date like this:

"SELECT * FROM TABLE WHERE (record_init_date >= #" & Me.selectorInitDate.Value & "#) AND (" & record_end_date & "<= #" & Me.selectorEndDate.Value & "#)"

But the result is not the desired one. How can I filter by date?

EDIT

Image some sample data like this:

id = 1
record_init_date = 10/11/2018
record_end_date = 20/11/2018

id = 2
record_init_date = 03/12/2018
record_end_date = 04/12/2018

If I run the query:

"SELECT ID FROM TABLE WHERE (record_init_date >= #01/11/2018#) AND (record_end_date <= #30/11/2018#)"

The expected result is the ID = 1

Could you provide some sample data and expect result?
– D-Shih
Jul 3 at 7:26

Could you be more specific? Please, provide sample data, final result and expected result.
– Maciej Los
Jul 3 at 7:26

Are you getting an error or a different result?
– IRENE G
Jul 3 at 8:03

1 Answer
1

You probably need to apply a format to obtain a date expression:

"SELECT * FROM TABLE WHERE record_init_date >= #" & Format(Me.selectorInitDate.Value, "yyyy/mm/dd") & "# AND record_end_date <= #" & Format(Me.selectorEndDate.Value, "yyyy/mm/dd") & "#"

By clicking “Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

excel VBA to select and paste issue

excel VBA to select and paste issue

I was having issue in the line

current.Worksheets(“Sheet1″).Range(“A14″).Select

I dont know what i did wrong and even to paste is also problem currently.

Sub copyall()

Dim lastrow As Long

lastrow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
MsgBox (lastrow)

Dim source As Workbook
Dim current As Workbook
Dim x As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False

For i = 1 To lastrow

x = Sheets("Sheet1").Cells(i, 1)

Set source = Workbooks.Open(x)
Set current = ThisWorkbook
'source.Worksheets("Adjustment").Columns.EntireColumn.Hidden = False
'source.Worksheets("Adjustment").Rows.EntireRow.Hidden = False

Dim f As Range
Set f = source.Worksheets("Adjustment").Cells.Find(what:="Adjustment Type", lookat:=xlWhole, MatchCase:=True)

Dim lastrow_source As Integer
y = source.Worksheets("Adjustment").Cells(f.Row + 1, f.Column)

lastrow_source = Sheets("Adjustment").Cells(Rows.Count, 1).End(xlUp).Row
MsgBox (y)
source.Worksheets("Adjustment").Range(source.Worksheets("Adjustment").Cells(f.Row + 1, f.Column), Cells(lastrow_source, 23)).Select
Application.CutCopyMode = False
Selection.Copy
current.Worksheets("Sheet1").Range("A14").Select
ActiveSheet.Paste
source.Close
MsgBox ("Imported")
Next i

End Sub

try with Selection.PasteSpecial Paste:=xlPasteValues instead of Activesheet.Paste
– IRENE G
Jul 3 at 7:42

Have a look about avoiding select, see this q & a as just one of many : stackoverflow.com/q/38833596/4961700
– Solar Mike
Jul 3 at 7:48

3 Answers
3

I would start by naming all the worksheets on the Project window in VBA. You have the window on your left.
Click on the sheet and name it.
Then you can call it without using Sheets(“") or Worksheets(“").

To copy paste in your case I would use this:

NameSheet1.Range("A14").Copy _ destination:= NameSheet2.Range("Input Range")

Let me know if that works.

I was having a lot of files to copy from that why have to name it worksheet but for my earlier line, the current does work correctly but after copy not working anymore
– terry
Jul 3 at 8:09

source.Worksheets("Adjustment").Range(source.Worksheets("Adjustment").Cells(f.Row + 1,
f.Column), Cells(lastrow_source, 23)).Copy _
Destination:=current.Sheets("HBA Billings").Range("H" & lastrow_HBA)

It would be great if you could add a little bit of an explanation on why and how this code provides an answer to the question.
– anothernode
Jul 3 at 9:22

These two lines should work:

Application.CutCopyMode = False
Source.Worksheets("Adjustment").Range(Source.Worksheets("Adjustment").Cells(f.Row + 1, f.Column), Source.Worksheets("Adjustment").Cells(lastrow_source, 23)).Copy current.Worksheets("Sheet1").Range("A14")

Instead of:

source.Worksheets("Adjustment").Range(source.Worksheets("Adjustment").Cells(f.Row + 1, f.Column), Cells(lastrow_source, 23)).Select
Application.CutCopyMode = False
Selection.Copy
current.Worksheets("Sheet1").Range("A14").Select
ActiveSheet.Paste

Above way is a good example of how to avoid Select and Selection, which is very advised!

Select

Selection

By clicking “Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Error 1004 ‘Range’ of object ‘_Worksheet’ failed when trying to copy values (Workbook and worksheet explicitly set, no named ranges)

Error 1004 ‘Range’ of object ‘_Worksheet’ failed when trying to copy values (Workbook and worksheet explicitly set, no named ranges)

My problem is stated in the title. The error occurs in the first line with .Copy, but I have had it the same as the second one and received the same error.

I have checked so that the Sheet names are correct, and even copied them straight from the Sheet title in case some weird character sneaked in.

I’ll put snippets of code here and then the full code in the end in case the problem is something different.

Declaration:
(I have tried setting it explicitly with Workbooks() but it didn’t help)
Dim wb As Workbook

Set wb = ThisWorkbook' Or Workbooks("collected.xlsm")
Dim sUser As Worksheet, sExceptions As Worksheet
Set sUser = wb.Sheets("User")
Set sExceptions = wb.Sheets("Exceptions")

Copying:

sUser.Range(Cells(rS, 1)).Copy Destination:=sExceptions.Range(Cells(Count, 1))
sUser.Range(rS, 11).Copy Destination:=sExceptions.Range(Count, 2)

Entire code:

Option Explicit

Function FindExceptions()

' To run faster
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

' Variable def
Dim Count As Integer

' Variable def
' Worksheets
Dim wb As Workbook
Set wb = ThisWorkbook ' Or Workbooks("collected.xlsm")
Dim sUser As Worksheet, sVCD As Worksheet, sFullExport As Worksheet
Set sUser = wb.Sheets("User")
Set sVCD = wb.Sheets("VCD")
Set sFullExport = wb.Sheets("FullExport")
' r, f, c = Search, Find, Check
' For Each rows
Dim rS As Integer, rF As Integer, rC As Integer
'Set rS = sUser.Columns("A")
'Set rF = sVCD.Columns("A")
'Set rC = sFullExport("B")
' Vars used in execution
'Dim cS As Range, cF As Range, cC As Range
Dim secId As String, employeeNum As String, FoundVCD As Boolean, FoundFullExport As Boolean

' Go through User sheet
For rS = 2 To sUser.UsedRange.Rows.Count
secId = sUser.Cells(rS, "A").Value
employeeNum = sUser.Cells(rS, "K").Value
' Search for in VCD
FoundVCD = False
For rF = 2 To sVCD.UsedRange.Rows.Count
If sVCD.Cells(rF, "A").Value = secId And sVCD.Cells(rF, "K").Value = employeeNum Then
FoundVCD = True
Exit For
End If
Next
'Search for in Full Export?
If FoundVCD = True Then
FoundFullExport = False
For rC = 2 To sFullExport.UsedRange.Rows.Count
If sFullExport.Cells(rC, "B").Value = secId Then
FoundFullExport = True
Exit For
End If
Next
End If

If FoundFullExport = False Then
' WriteExceptions sUser.Cells(rS, "A").Value, sUser.Cells(rS, "K").Value, sFullExport.Cells(rC, "A").Value, sFullExport.Cells(rC, "D").Value

' Worksheet var
Dim sExceptions As Worksheet
Set sExceptions = wb.Sheets("Exceptions")

If Count = Null Or Count = 0 Then
sExceptions.Cells(1, "A") = "Säk. Id"
sExceptions.Cells(1, "B") = "Anst. Nr"
sExceptions.Cells(1, "C") = "Unison Id"
sExceptions.Cells(1, "D") = "Kort hex"
Count = 2
Else
Count = Count + 1
End If

' secId on col A, employeeNum on col B, unisonId on col C, cardHex on col D
sUser.Range(Cells(rS, 1)).Copy _
Destination:=sExceptions.Range(Cells(Count, 1))
sUser.Range(rS, 11).Copy _
Destination:=sExceptions.Range(Count, 2)
sFullExport.Range(rC, 1).Copy _
Destination:=sExceptions.Range(Count, 3)
sFullExport.Range(rC, 4).Copy _
Destination:=sExceptions.Range(Count, 4)
End If

Next

Count = 0

' To end settings to run faster
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Function

you are missing cells inside Range(count,2): Range(Cells(count,2)), or you could use just cells(count,2) too… if by changing these it still doesn’t work I’ll try with “.PasteSpecial" instead of using “destination:="
– IRENE G
Jul 3 at 7:36

1 Answer
1

You’re confusing Range and Cells.

Range

Cells

Try

sUser.Cells(rs, 1).Copy _
Destination:=sExceptions.Cells(count, 1)
sUser.Cells(rs, 11).Copy _
Destination:=sExceptions.Cells(count, 2)
sFullExport.Cells(rC, 1).Copy _
Destination:=sExceptions.Cells(count, 3)
sFullExport.Cells(rC, 4).Copy _
Destination:=sExceptions.Cells(count, 4)

Hi this solved the problem. Thanks a lot.
– Catfish
Jul 3 at 8:40

By clicking “Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Error reading Outlook HTML Body

Error reading Outlook HTML Body

I’m getting error 438 : object doesn't support this property or methodwhen I am trying to run the macro on a new machine:

error 438 : object doesn't support this property or method

Set HTMLdoc = New MSHTML.HTMLDocument
With HTMLdoc
.body.innerHTML = OutlookMail.HTMLBody **'******** Error Line**
Set tables = .getElementsByTagName("table")
End With

There is apparently such thing as a text to code ratio for SO. Your not quite Minimal, Complete, and Verifiable example, though minimal, could do with more text explanation. What have you tried? And this worked on a prior machine did it? What are the differences between machines? How is OutlookMail declared and set? I have also formatted your code correctly.
– QHarr
Jul 3 at 7:39

This may be because of the references, have you check that you setup the same refenrence s in the visual basic editor?
– IRENE G
Jul 3 at 7:40

@QHarr I’m not sure why the Text-to-Code ratio only prevents posting of the question certain times… but it prevents questions from being posted with more than (I think) 3:1 text to code ratio… however in this case the lengthy title might help. I’ll ask Sam. 🙂
– ashleedawg
Jul 3 at 7:47

2 Answers
2

Yes it is working fine in my system. But when I tried to install this in new system, it creates this error.

No changes in the code, I am running the same excel macro file on some outllok mails.
Even the outlook mails which I used for testing, i am using the same files in the new machine.

Also, the Tool>>Reference libraries, I have checked all the Items like MS HTML object library, MS Outlook 16.0 Object library and other default checkboxes are maintained same in the system.

The code abruptly breaks when it reaches this line :
. Body. Innerhtml = Outlookmail. HTMLBody

.body.innerHTML = OutlookMail.HTMLBody

The inner HTML markup of the body doesn’t equal to the HTML markup of the Outlook’s message body. It includes other outer html markup that should be removed before.

Anyway, VBA macros are not designed for distributing them on multiple machines. That is exactly COM add-ins were introduced for. In that case you will be able to create an installer for your solution to get it deployed automatically for all users. Moreover, you will be able to check and install (if needed) the required prerequisites at the installation time. See Walkthrough: Create your first VSTO Add-in for Outlook to get started quickly.

By clicking “Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Looping through Rows to Validate their Content with VBA in Excel

Looping through Rows to Validate their Content with VBA in Excel

I have a xls-file which contains several date-columns. I change the background-color of the rows depending on the content of the row.

Here is my problem: When i enter a invalid value on row 10 and 100. Every row from 7 to 100 is getting checked and 10th and 100th row is colored red. (I start at row 7 because there are some headerrows). When i now delete the text in the 100th row. The loop only goes to the 10th row and ends. Obviously because 10 is the last used row. But the 100th row is still colored in red.
Thats because my loop colors the rows wihtout content to no color. And i only loop through the columns that have values.

Any ideas to solve my problem?

Here is my VB-Code:

Private Sub Worksheet_Change(ByVal Target As Range)
CheckAllDateCells
End Sub
Private Sub CheckAllDateCells()
CheckDateCellsForColumn "T", 7
CheckDateCellsForColumn "V", 7
CheckDateCellsForColumn "X", 7
CheckDateCellsForColumn "Y", 7
CheckDateCellsForColumn "AI", 7
CheckDateCellsForColumn "AJ", 7
CheckDateCellsForColumn "AK", 7
CheckDateCellsForColumn "AL", 7
CheckDateCellsForColumn "AM", 7
CheckDateCellsForColumn "AN", 7
CheckDateCellsForColumn "AO", 7
CheckDateCellsForColumn "AP", 7
End Sub
Private Sub CheckDateCellsForColumn(column As String, firstRowIndex As Long)
For i = firstRowIndex To Me.Range(column & Me.Rows.Count).End(xlUp).row
CheckDateCell i, Me.Range(column & 1).column
Next i
End Sub
Private Sub CheckDateCell(ByVal rowIndex As Long, ByVal columnIndex As Long)
If Not IsEmpty(Cells(rowIndex, columnIndex).value) Then
If IsDate(Cells(rowIndex, columnIndex).value) Then
If Cells(rowIndex, columnIndex).value Like "##.##.####" Then
Cells(rowIndex, columnIndex).Interior.ColorIndex = 10
Else
Cells(rowIndex, columnIndex).Interior.ColorIndex = 6
End If
Else
Cells(rowIndex, columnIndex).Interior.ColorIndex = 3
End If
Else
Cells(rowIndex, columnIndex).Interior.ColorIndex = 0
End If
End Sub

Maybe i can achive this wihtout using vb? only conditional formatting?

conditional formatting just gives me the possibillity to color cells on specific criteria, like date is yesterday or date is from this month etc. But i can not select a daterange by myself like date is between 01.01.1899 and 01.01.2999…

Please remember to check a tag’s description before adding it to your question. VB.NET is not the same thing as VBA.
– Visual Vincent
18 hours ago

If I understand correctly, you basically need to just reset all the cells to “No Colour" – if it’s a viable quick fix, just say something like cells(1, column).EntireColumn.Interior.Color = xlNone at the very start? Or even just stick a +100 on your For i = firstRowIndex To Me.Range(column & Me.Rows.Count).End(xlUp).row line to make it loop 100 rows past the last row
– jamheadart
18 hours ago

cells(1, column).EntireColumn.Interior.Color = xlNone

+100

For i = firstRowIndex To Me.Range(column & Me.Rows.Count).End(xlUp).row

I’m with @jamheadart. I’d recommend resetting your entire column to no color at the beginning of the macro used to shade the invalid rows.
– TempleGuard527
18 hours ago

cells(1, column).EntireColumn.Interior.ColorIndex = 0; works, But it takes a little bit too long. I have to wait like 2 seconds. This makes a bad workflow. For the first, i will stick to the +100 on my loop if i will not find a better solution.
– Olli
18 hours ago

You have several date-columns and want to change the background-color of the rows, so what do you want to happen to a row that contains both a valid and an invalid format?
– pnuts
18 hours ago

1 Answer
1

You can stick + 100 to your loop count so that it goes 100 rows past the last row that contains data (but this looping through empty cells so is a bit “hacky")

For i = firstRowIndex To Me.Range(column & Me.Rows.Count).End(xlUp).row + 100

For i = firstRowIndex To Me.Range(column & Me.Rows.Count).End(xlUp).row + 100

You can reset the entire column right at the start (but this is proving to be slow – EntireColumn is a big object!):

cells(1, column).EntireColumn.Interior.Color = xlNone

cells(1, column).EntireColumn.Interior.Color = xlNone

Best idea is a combo of both – reset the Range you’re doing in one go using the last row + 100 so no looping further than required (100 being a sortof arbitrary number assuming you don’t delete more than 100 rows before running, could easily be 1000 which is still tiny compared to “EntireColumn")

Private Sub CheckDateCellsForColumn(column As String, firstRowIndex As Long)
Dim lROW As Long: lROW = Me.Range(column & Me.Rows.Count).End(xlUp).Row
Me.Range(column & firstRowIndex & ":" & column & lROW + 100).Interior.Color = 0
For i = firstRowIndex To lROW
CheckDateCell i, Me.Range(column & 1).column
Next i
End Sub

By clicking “Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Vba code to check if produced pieces are greater than 104%

Vba code to check if produced pieces are greater than 104%

Hello I am Trying To Create an Vba Code Check, a Po numbers Produced pieces is above 104%, so the program would take the Po. and the produces pieces as input and would check if the produced pieces exceeds 104% and return an error.

This Would allow the user to input the Po.number

Public Sub Pobox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim x As Integer
x = 1
Dim trovato As Boolean 'found=trovato
trovato = False
'Dim Labelstyle, Labelcolor As String

'Sheets("PO summary").Activate
Do Until Sheet2.Cells(1 + x, 1) = ""
If Sheet2.Cells(1 + x, 1) = Pobox.Value Or Sheet2.Cells(1 + x, 10) = Pobox.Value Then
Labelstyle = Sheet2.Cells(1 + x, 13)
Labelcolor = Sheet2.Cells(1 + x, 14)
trovato = True
End If
x = x + 1
Loop
'Sheets("INSERT").Activate

If trovato = False And Pobox.Value <> "" Then
MsgBox "PO not valid"
Pobox.Value = ""
End If

End Sub

And This Would Search for the Po.Number and if found, it would then Check for Size same row but different column, and lastly if it finds the last two it would check the Produced Pieces and Check if its greater than 104% then it would return error

Private Sub Lbox_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii > 58 Or KeyAscii < 48 Then
KeyAscii = 0
MsgBox ("enter number ")
Lbox.SetFocus
End If
With Worksheets(4).Range("j2:j1048576")
Set c = .Find(Pobox.Value, LookIn:=xlValues)
End With
If Not c Is Nothing Then
With Worksheets(4).Range("s2:s1048576")
Set d = .Find("L", LookIn:=xlValues)
End With
If Not d Is Nothing Then

With Worksheets(4).Range("u2:u1048576")
Set d = .Find("L", LookIn:=xlValues)
End With
If e > 1.04 Then
MsgBox "Too Large "
End If
End If
End If
End Sub

What is the issue exactly?
– Tom
Jul 3 at 9:44

1 Answer
1

I’m not sure what “L" or “e" are but apart from that I’ll try using a loop:

Sub Lbox_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)

If KeyAscii > 58 Or KeyAscii < 48 Then
KeyAscii = 0
MsgBox ("enter number ")
Lbox.SetFocus
End If

With ActiveSheet.UsedRange

Set c = .Cells.Find(What:="d", SearchOrder:=xlByRows)

If Not c Is Nothing Then
Do Until c Is Nothing

If c.Column = 10 Then

Set d = .Cells(c.Row).Find(What:="L", SearchOrder:=xlByRows)

If Not d Is Nothing Then

Set d = .FindNext(d)

If Not d Is Nothing Then
Do Until d Is Nothing
Set d = .FindNext(d)
If d.Column = 21 Then

If e > 1.04 Then

MsgBox "Match"

End If

End If
Loop
End If

End If
End If
Set c = .FindNext(c)
Loop
End If

End With

End Sub

Sorry, I was just trying to help based on the user issue, I don’t understand your negative 😦
– IRENE G
Jul 3 at 14:27

You’ve removed there Find which is fairly efficient way of doing it and instead are testing every single cell in the sheet column which is incredibly verbose. You’re also not handling your MsgBox very well and creating the possibility for 1048576 Message boxes to be shown to the user
– Tom
Jul 3 at 15:02

Find

MsgBox

Based on the user question it seems he/she wants a MsgBox when the value is found…. There is no need for being so rude, I was just trying to help the user… I edited my post anyway, to include the .Find, hope you feel better now! 🙂
– IRENE G
Jul 3 at 15:16

By clicking “Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Bloomberg VWAP Interval

Bloomberg VWAP Interval

Screenshot of Bloomberg

I am trying to use the open Bloomberg API to gather the VWAP volume on a specific date for a specific time range.

But with this formula:

BDP(DHR US Equity; "VWAP_VOLUME"; "VWAP_START_TIME=15:54:00"; "VWAP_END_TIME=15:55:00"; "VWAP_START_DT=20180629"; "VWAP_END_DT=20180629")

I get the data Volume (3,552), but I want the data from the VWAP cell (99,0245).

Volume

VWAP

Is that possible?

1 Answer
1

If you replace the field by EQY_WEIGHTED_AVG_PX you should get your answer.

EQY_WEIGHTED_AVG_PX

There’s also VWAP for real time updates but I think it only works for the current trading session (not historical data).

VWAP

By clicking “Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Automate to arrange Data

Automate to arrange Data

Got any Way to Arrange The data like the picture attached?

*the requirement is when the Column A Cell is empty then Column B Value will Move to previous not Empty Column A Row at Column B Cell.

Example Photo

1 Answer
1

Try this code

Sub Macro1()

Dim i As Long
i = 1
Do Until Cells(i, 2) = ""
If Cells(i, 1) = "" Then
On Error Resume Next
Cells(i - 1, 2) = Cells(i - 1, 2) & "," & Cells(i, 2)
Cells(i, 2).EntireRow.Delete
i = i - 1
End If
i = i + 1
Loop

End Sub

worked,Thanks you very much!
– step
Jul 3 at 7:58

do you have anyway to sorting this?for example like if Column A got same data then will combine together(not duplicate data).thanks
– step
Jul 3 at 14:59

By clicking “Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.