Saltar al contenido

How to Make the First Issue of the Past Month Appear as (26) which was on Monday


Recommended Posts

publicado

Hello everyone from Maurizio
My problem is this .
I'm trying but failing to want to create some sort of Calendar
Slo that my problem with the vba is this:
in a userform I inserted a Textbox and Seven Labels, of which 6 are classified as (Cella1,Cella2,Cella3) etc...!
And I want them to stay that way.

While a label the name has remained unchanged and is called (Label3)

Now what I would like to get from vba code, and that every time I start the userform the Labels classified as (Cella1 etc ...! the number "26" is reported which corresponds to the number of the month of December which was (Monday ) and gradually all the other ends to reach (1) of the following week which corresponds to the Number of the beginning of this month.

In addition, if it were possible, I would like to be able to make the start date of the month appear in (Label3) as a code, as I manually reported, to better understand "01/01/2023"

Clearly if I change the date in the Texbox these data must be able to change accordingly.

I don't expect you to do all the work for me It would be enough for me
just to see the Number (26) appear in the label (Cella1) and the start date of the month in (Label3)
Thank you
Greetings from A.Maurizio

Numero_Setimana_Inizio_Mese.xlsm

publicado

Ciao Antony
Ascolta ho pensato che avrei potuto da qui in poi per poter risolvere il mio problema seguendo le tue direttive; Che come sempre sono fantastici.
Ma ho provato a dargli altre direttive, ma non funziona come vorrei.
Quindi ascolta: potresti dare un'occhiata al mio file
excel e provare a fare la stessa cosa solo usando il vba all'interno del modulo .

Mi spiego: sul foglio Excel nella colonna (A1:A5) avevo estratto tutti i dati necessari per formare un calendario molto semplice.
Facendo così:

1) data odierna (=Ora())2) L'anno (=Anno(A1))3) Inserisco l'anno come testo e lo trasformo come inizio del mese (01/01/2023 )

utilizzando questa funzione (=DATA(A2; A4;1))
4) Estraggo la media Dalla data odierna (=DATA(A2; A4;1))
5 ) Infine estraggo il numero del giorno della settimana
Dall'inizio del mese mese che è uguale a "26" ( = MESE(A1))

Il resto delle celle del foglio Excel mostra i vari numeri del mese seguendo questa logica:nella cella (B4) che corrisponde al "26" Giorno del mese precedente ho scritto( =(A3-WEEKDAY(A3,3))Pur partendo dalla Cella (C4) e gradualmente per tutte le altre ho appena scritto
:

(=B4+1)
; (=C4+1) ; (=D4+1) ecc...!

Ora quello che vorrei sapere è se fosse possibile a livello di modulo; Ma senza collegamenti al foglio Excel.
Essere in grado di ripetere la stessa cosa con il vba.

Questo è tutto?
Sto pubblicando il mio lavoro fatto qualche tempo fa a livello di foglio; Quindi puoi dargli un'occhiata più da vicino E se fosse
possibile, non potresti non usare l'etichetta (Dynamics)
Ma solo chiamandoli (Cell1); (Cella2) ecc...!
Grazie. Sei fantastico come sempre.
Saluti da Maurice

 

Calendario Per Enrico.xlsm

publicado

Hello @A.Maurizio,

 

I so not understand very well what you want to do (well, yes, a calendar...) , but no why in this way. You have a calendar (made by @Antoni) in the download section.

Maybe it is what you need

publicado

Hi Haplox Thanks for your support
And this work is beautiful
But it's far from what I want to do, I just lack the initial steps to get all that basic information.
That's all
Thanks again for everything both you and Antoni
I'll try to better understand what the difference is between the vba and the formulas entered on the excel sheet.
Thanks again for everything and above all thanks for your time that you have dedicated to me.
Greetings to rurri with Friendship from A.Maurizio

 

publicado

Hi Antony
Not !
I would like to get a calendar on a form exactly as you proposed
only instead of moving the boxes of the names of the Week (Mon);(Tue);(Wed) etc...!
Make the numbers move only within the various Boxes exactly as you see in my calendar Proposed on the excel sheet.
Only that you should repeat the same thing but only in the form.

Another small example: I managed to put all the items you see in the column of the excel sheet ranging from (A1:A4) using only a Text to change the date from time to time.
Three Labels For (Day Month Year)
and a last Label which shows the date of the beginning of the current month.
Example: If today the date is shown in the text (01/17/2023) the last label is written like this (01/01/2023)
Now where is the problem !
That in the first label that makes up the scheme of our calendar; Exactly as you see it on the excel sheet
Because everything can work well even in the form
You should understand how to write this Code in vba format:" =A3-(WEEKDAY(A3,2)-1) "
Which in a nutshell would mean:
Get the number of the month that is on the Month label
Subtract it from the Day of the Week
And you transform it from the text format to the number 2 which corresponds to the day Of (Monday) minus 1 which to tell the truth I didn't quite understand why the excel formula you want it done this way that's all!
A bit like you can see in the image below

Only in this case it's at the level of the excl sheet
While I would like to do exactly that only using a form with its cells as labels

Link Project Now :
https://app.box.com/s/3nbyn726mwpduitfblk9ejlm35v8f0ll

  • 2 weeks later...
publicado

Hi Anthony how are you!
As always, you have outdone yourself

as your project is Beautiful and there is much more
As I noticed that: if you click on a Date it Generates Another Calendar
And all of this is wonderful
Thanks Infinite
Greetings to you and all the rest of your AyudaExcel Staff
From A.Maurizio

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

  • 109 ¿Te parecen útiles los tips de las funciones? (ver tema completo)

    1. 1. ¿Te parecen útiles los tips de las funciones?


      • No
      • Ni me he fijado en ellos

  • Ayúdanos a mejorar la comunidad

    • Donaciones recibidas este mes: 0.00 EUR
      Objetivo: 130.00 EUR
  • Archivos

  • Estadísticas de descargas

    • Archivos
      188
    • Comentarios
      98
    • Revisiones
      29

    Más información sobre "Cambios en el Control Horario"
    Última descarga
    Por pegones1

    4    1

  • Crear macros Excel

  • Mensajes

    • Buenos días  @LeandroA espero estes bien Tengo un caso idéntico al planteado en la siguiente pregunta: Sin embargo, a diferencia de quien planteo originalmente la pregunta al correr el código no obtengo ningún resultado podrían ayudarme a resolver este inconveniente y que al hacer click en el Botón Guardar (CommandButton3) del Formulario RCS (frmrcs) el archivo pdf quede configurado con orientación vertical, márgenes superior, inferior, derecho e izquierdo = 1 y en página tamaño carta. Si acaso influye uso Microsoft Excel LTSC MSO (versión 2209 Compilación16.0.1.15629.20200) de 64 bits Mucho le sabre agradecer la ayuda que me pueda dar  RCS PRUEBA - copia.xlsm
    • @JSDJSDCon gusto mi estimado Para la opción 1: Sub Surtirhastadondealcanse() Dim ws As Worksheet Set ws = ThisWorkbook.Sheets(1) Dim filaInicio As Integer: filaInicio = 4 Dim filaFin As Integer: filaFin = 7 Dim colInventario As Integer: colInventario = 2 Dim colSolicitudesInicio As Integer: colSolicitudesInicio = 4 ' Columna C Dim colResultadoInicio As Integer: colResultadoInicio = 9 ' Columna I Dim colTotalSurtido As Integer: colTotalSurtido = 12 ' Columna L Dim colFinalInventario As Integer: colFinalInventario = 13 ' Columna M Dim numClientes As Integer: numClientes = 3 Dim fila As Integer, i As Integer For fila = filaInicio To filaFin Dim inventario As Double inventario = Val(ws.Cells(fila, colInventario).Value) Dim solicitudes(1 To 3) As Double Dim surtido(1 To 3) As Variant Dim totalSurtido As Double: totalSurtido = 0 ' Leer solicitudes For i = 1 To numClientes If IsNumeric(ws.Cells(fila, colSolicitudesInicio + i - 1).Value) Then solicitudes(i) = CDbl(ws.Cells(fila, colSolicitudesInicio + i - 1).Value) Else solicitudes(i) = 0 End If surtido(i) = "POR FALTA STOCK" Next i ' Surtir de acuerdo al inventario disponible For i = 1 To numClientes If solicitudes(i) > 0 Then If inventario >= solicitudes(i) Then surtido(i) = solicitudes(i) inventario = inventario - solicitudes(i) totalSurtido = totalSurtido + solicitudes(i) ElseIf inventario > 0 Then surtido(i) = inventario totalSurtido = totalSurtido + inventario inventario = 0 Else surtido(i) = "POR FALTA STOCK" End If End If Next i ' Escribir resultados en las columnas correspondientes para cada cliente For i = 1 To numClientes With ws.Cells(fila, colResultadoInicio + i - 1) If surtido(i) = "POR FALTA STOCK" Then .Value = surtido(i) .Font.Color = vbRed Else .Value = surtido(i) .Font.Color = vbBlack End If End With Next i ' Escribir total surtido y existencia final ws.Cells(fila, colTotalSurtido).Value = totalSurtido ws.Cells(fila, colFinalInventario).Value = inventario Next fila MsgBox "Resultado surtido cargado con éxito...", vbInformation End Sub Para la opción 2:   Sub surtirenpartesiguales() Dim ws As Worksheet Set ws = ThisWorkbook.Sheets(1) Dim filaInicio As Integer: filaInicio = 13 Dim filaFin As Integer: filaFin = 16 Dim colInventario As Integer: colInventario = 2 Dim colSolicitudesInicio As Integer: colSolicitudesInicio = 4 ' Columna C Dim colResultadoInicio As Integer: colResultadoInicio = 9 ' Columna I Dim colTotalSurtido As Integer: colTotalSurtido = 12 ' Columna L Dim colFinalInventario As Integer: colFinalInventario = 13 ' Columna M Dim numClientes As Integer: numClientes = 3 Dim fila As Integer, i As Integer For fila = filaInicio To filaFin Dim inventario As Double inventario = Val(ws.Cells(fila, colInventario).Value) Dim solicitudes(1 To 3) As Double Dim surtido(1 To 3) As Variant Dim totalSurtido As Double: totalSurtido = 0 Dim totalPedido As Double: totalPedido = 0 ' Leer solicitudes For i = 1 To numClientes If IsNumeric(ws.Cells(fila, colSolicitudesInicio + i - 1).Value) Then solicitudes(i) = CDbl(ws.Cells(fila, colSolicitudesInicio + i - 1).Value) totalPedido = totalPedido + solicitudes(i) Else solicitudes(i) = 0 End If surtido(i) = 0 Next i ' Si hay suficiente inventario, surtir lo que el cliente pide If inventario >= totalPedido Then For i = 1 To numClientes If solicitudes(i) > 0 And inventario >= solicitudes(i) Then surtido(i) = solicitudes(i) inventario = inventario - solicitudes(i) totalSurtido = totalSurtido + solicitudes(i) End If Next i Else ' Reparto base igualitario Dim baseSurtido As Long baseSurtido = Int(inventario / numClientes) For i = 1 To numClientes If solicitudes(i) > 0 Then If solicitudes(i) <= baseSurtido Then surtido(i) = solicitudes(i) inventario = inventario - solicitudes(i) totalSurtido = totalSurtido + solicitudes(i) Else surtido(i) = baseSurtido inventario = inventario - baseSurtido totalSurtido = totalSurtido + baseSurtido End If End If Next i ' Repartir sobrante restante uno por uno, respetando lo pedido Do While inventario > 0 For i = 1 To numClientes If surtido(i) < solicitudes(i) Then surtido(i) = surtido(i) + 1 totalSurtido = totalSurtido + 1 inventario = inventario - 1 If inventario = 0 Then Exit For End If Next i Loop End If ' Escribir resultados en las columnas correspondientes para cada cliente For i = 1 To numClientes With ws.Cells(fila, colResultadoInicio + i - 1) If surtido(i) = 0 Then .Value = "POR FALTA STOCK" .Font.Color = vbRed Else .Value = surtido(i) .Font.Color = vbBlack End If End With Next i ' Escribir total surtido y existencia final ws.Cells(fila, colTotalSurtido).Value = totalSurtido ws.Cells(fila, colFinalInventario).Value = inventario Next fila MsgBox "Resultado surtido cargado con éxito...", vbInformation End Sub Saludos, Diego
    • Buenos dias.  Estoy trabajando en una hoja para poder llevar un control de un pequeño almacén.  Tengo un pedido con varias líneas y "lotes" y necesito sacar las ubicaciones que coincidan con la referencia y lote que pone en el pedido. El problema viene cuando tengo la misma referencia y mismo lote en ubicaciones diferentes y necesito sacar la información en columnas diferentes. No se si  me he explicado bien, pero creo que con el ejemplo adjunto se entiende mejor. Agradecería mucho si me pudieran ayudar  Libro1.xlsx
    • Exelente solución mil gracias 
    • Podrías compartir tu solucion
  • Visualizado recientemente

    • No hay usuarios registrado para ver esta página.
×
×
  • Crear nuevo...

Información importante

Echa un vistazo a nuestra política de cookies para ayudarte a tener una mejor experiencia de navegación. Puedes ajustar aquí la configuración. Pulsa el botón Aceptar, si estás de acuerdo.