Author | Post | |||
sniperkid |
Im sure its quite possible to do but it seems quite impossible for me This is basically what i was looking for; 1. A macro button that asks for a number (when clicked). 2. It searches a row (just 1 row) for the string. 3. It then checks the column of that row to see how many blank values are in it ( = 0 in a specified area). 4. It prints out values in the row (specified). Any help or bits of code that would help me achieve this would be very much appreciated. |
|||
25.05.2006 07:40:43 |
|
|||
Inferno |
Like always, google knows..... |
|||
25.05.2006 11:55:34 |
|
|||
unknown user |
just quickly write it in vba. |
|||
25.05.2006 12:19:16 |
|
|||
sniperkid |
hands up those who know vba . |
|||
25.05.2006 15:22:20 |
|
|||
bb |
http://spreadsheets.about.com/cs/exceladvanced/a/vba1index.htm looks like a good place to start. Else try http://www.google.co.uk/search?q=vba+for+beginners bb |
|||
25.05.2006 19:58:55 |
|
|||
sniperkid |
ok after a bit of research i have found the following code which almost does exactly what i want. Sheets("Sheet1").Select ' Find the last row of data FinalRow = Range("A65536").End(xlUp).Row ' Loop through each row For x = 3 To FinalRow ThisValue = Range(col & x).Value 'Range("") = column to look in If ThisValue = 0 Then Range("B" & x & ":F" & x).Copy Sheets("test").Select Nextrow = Range("A65536").End(xlUp).Row + 1 Range("A" & Nextrow).Select ActiveSheet.Paste Range("F" & Nextrow).Value = strweek Sheets("Sheet1").Select ElseIf ThisValue = 0 Then Range("B" & x & ":F" & x).Copy Sheets("test").Select Nextrow = Range("A65536").End(xlUp).Row + 1 Range("A" & Nextrow).Select ActiveSheet.Paste Sheets("Sheet1").Select End If Next x End Sub the problem is the "Range(col & x)" They enter a number and it should search row 2 and find that string (it will only appear once) and then it needs to get the column name (A, B, C, D...etc) and that var will be col...just not sure how to do it so atm i have done a little example where it will only work for values 40 - 53 and its a IF statement which changes the col var: If strweek = 40 Then col = "AT" ElseIf strweek = 41 Then col = "AU" ElseIf strweek = 42 Then col = "AV" ElseIf strweek = 43 Then col = "AW" ElseIf strweek = 44 Then col = "AX" etc im sure there is a way to do this auto but cant seem to find a solution . |
|||
Edited by sniperkid on 31.05.2006 12:08:18 | ||||
31.05.2006 12:07:31 |
|
|||
Caesum |
I'm not really sure what you're doing here, but generally when programming in Excel it's easier to use things like cells(row,col).value and to find the last row I normally use usedrange.rows.count to compute it. |
|||
08.06.2006 21:04:21 |
|
|||
sniperkid |
Thanks to aceldama i have solved this little problem . |
|||
08.06.2006 22:53:27 |
|
|||
aceldama |
oh, it worked? you never told me! glad to be of service though... |
|||
08.06.2006 23:18:17 |
|