Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
¡Hola!
Así que tengo acceso a una hoja de Excel de mi empresa. Pero en este archivo solo tiene los últimos cinco meses y actualmente mes, cada uno es una columna.
Pero necesito un análisis del año actual, por lo que quiero alguna forma de transferir automáticamente la columna del mes más antiguo a otra hoja.
Hola @denisetiburzivc ,
No he tenido noticias tuyas en un tiempo y quería hacer un seguimiento. ¿Has tenido la oportunidad de probar las soluciones que se han ofrecido? Si el problema se ha resuelto, ¿puede marcar la publicación como resuelta? Si todavía tienes desafíos, no dudes en hacérnoslo saber y estaremos encantados de seguir ayudándote.
¡Esperamos su respuesta!
Sub TransferOldestMonthColumn()
Dim wsSource como hoja de cálculo
Dim wsTarget como hoja de cálculo
Dim lastColumn As Integer
Dim oldestMonthColumn As Integer
' Reemplace "Hoja1" con el nombre real de su hoja de origen
Establecer wsSource = ThisWorkbook.Sheets("Sheet1")
' Encuentre la última columna con datos
lastColumn = wsSource.Cells(1, Columns.Count). Fin(xlToLeft). Columna
' Determine la columna del mes más antiguo en función de los encabezados de columna
oldestMonthColumn = Application.Match(WorksheetFunction.Min(wsSource.Range(Cells(1, 1), Cells(1, lastColumn))), wsSource.Range(Cells(1, 1), Cells(1, lastColumn)), 0)
' Crear una nueva hoja para los datos transferidos
Establezca wsTarget = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
wsTarget.Name = "Datos del mes más antiguo"
' Transfiera la columna del mes más antiguo a la nueva hoja
wsSource.Columns(oldestMonthColumn). Copiar wsTarget.Columns(1)
' Eliminar la columna del mes más antiguo de la hoja de origen
wsSource.Columns(oldestMonthColumn). Borrar
Fin de la substitución
Puede ajustar los nombres de las hojas ("Hoja1" y "Hoja2") según sea necesario.
Como alternativa, puede usar Power Query para transferir manualmente la columna del mes más antiguo:
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.