Home > Software engineering >  Excel vba for help, how to position specified content on cell coordinates
Excel vba for help, how to position specified content on cell coordinates

Time:10-28

As shown in figure, red and green arrow marks the second row in the table is part of the same name events, will be able to distinguish between the condition is that the first line of the red big green circle, how to choose the specified alone under the categories of four events

CodePudding user response:

This table column name is not changing every day, according to the number of columns to get directly is ok, the average hospitalization days, 2-6 columns, bed utilization rate, seven to eight columns,

CodePudding user response:

reference 1/X - I - n reply:
this table column name is not changing every day, according to the number of columns to get directly is ok, the average hospitalization days, 2-6 columns, bed utilization rate, seven to eight columns,
monthly change, with people don't understand the change of parameters, I want to do is perfect

CodePudding user response:

reference beam on the second floor of mulberry response:
Quote: refer to 1st floor X - I - n reply:
this table column name is not changing every day, according to the number of columns to get directly is ok, the average hospitalization days, 2-6 columns, bed utilization rate, seven to eight columns,
monthly change, with people don't understand the change of parameters, I just want to do a perfect

Column head monthly change? It should go to beat the man change the column header

CodePudding user response:

reference 3 floor crispy large ice cream response:
Quote: refer to the second floor beam mulberry response:

Quote: refer to 1st floor X - I - n reply:
this table column name is not changing every day, according to the number of columns to get directly is ok, the average hospitalization days, 2-6 columns, bed utilization rate, seven to eight columns,
monthly change, with people don't understand the change of parameters, I just want to do a perfect

Column head monthly change? It should go to beat the man change the column head
imparted to him a code farmer's anger

CodePudding user response:

Use the find/average hospitalization days and the location of the [bed], and then get the second line from the find place to the last column of a row to array arr
And then use the custom function below, the second parameter false from right to left, corresponding [points] and [for] column, with dic (" points ") is ok, pay attention to get the position of the number of columns is not listed in the Excel table, if you need to Excel in the position of the columns need to add the find cell in the column 1

 'access to fields, the corresponding relationship between columns returns a dictionary (field unified capital) 
'order_asc=true look from left to right, false from right to left to see
The Function CollectionFields (ByVal arr As the Variant, Optional ByVal order_asc As Boolean=True)
Dim col As Long, lstcol As Long
Dim n As Long
Dim dic As Object
Dim the item As a String
The Set dic=CreateObject (" scripting. The dictionary ")

Dim begin_col As Long, end_col As Long, bystep As Integer
Lstcol=UBound (arr, 2)

If order_asc Then
Begin_col=LBound (arr, 2)
End_col=lstcol
Bystep=1
The Else
Begin_col=lstcol
End_col=LBound (arr, 2)
Bystep=1
End the If

For col=begin_col To end_col Step bystep
N=col - LBound (arr, 2) + 1
The item=arr (1, col)
'remove newline characters and Spaces
Item=Replace (item, vbLf, "")
Item=Replace (item, vbCr, "")
The item=Replace (item, ""," ")

Dic (UCase (item))=n
Next col
The Set CollectionFields=dic
End the Function

  •  Tags:  
  • VBA
  • Related